Unity general questions

Comments


  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    Hey

    So I have been having problems with addTorque for a rigidbody2D. Sometimes it adds torque other times it doesn't. There is also a force applied just before the torque. I don't know if I am doing something wrong or understanding something wrong.

    The code is just addForce then add Torque -500

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    loet said:
    Hey

    So I have been having problems with addTorque for a rigidbody2D. Sometimes it adds torque other times it doesn't. There is also a force applied just before the torque. I don't know if I am doing something wrong or understanding something wrong.

    The code is just addForce then add Torque -500
    Are you calling this in fixedUpdate (every fixed frame)?
    Other possibilities are the object may be too heavy, or drag too much, or perhaps a rigidbody setup mistake.

    (It will be helpful if you post the full code, as well as a screeny of your rigidbody setup).




  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    Hey guys, time for more general unity questions! :D *gameshow fanfare*

    I have an array of AudioClips, and right now I'm populating them by manually dragging them from projects to the inspector in the editor...

    But now I'm reaching like 100 samples... So it's a heck of a drag to drag (pun intended).

    Is there a way to do a for loop to pull a pile of files into an array based on its name in projects? So... Constructing names in string "audio file name " + n (to get "audio file name 1" for example) and have that name reference something from the library to push into an array?

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    Yeah, you can. :) I imagine you'd want to use something like the Directory.GetFiles() method (which gets you an array of files' names), combined with AssetDatabase.LoadAssetAtPath() (which gets you the actual asset files).

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281

    Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    edited
    What @Elyaradine suggests will only work in the editor, though. So you can use that technique to write an editor script that can populate your list for you automatically. Alternatively, you can load assets dynamically by using Resources.Load() with some path relative to a Resources/ folder in your project, which you can do at runtime.

    If you're getting into editor scripting, you can also technically write your own inspectors for the object that contains your array so that you simply drag in a whole big list of files from projects and have it populate on its own, or, in fact, do whatever the hell you want! Unity's extensible editor is a rabbit hole that goes a long, long, long way down.

    EDIT:
    Also remember that if you ARE using editor scripting to change an object in your scene or a prefab in your project, make sure to call EditorUtility.SetDirty() on it or things will behave very very strangely indeed (values will appear to change but updates will not be committed).

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    Editor... scripting? What is that? :/ I'm a bit lost as to what you're talking about here. Been looking at Directory.GetFiles(), starting from there... Not sure what it does yet. And googling is coming up with a bunch of very technical looking things, and I'm working through them...

    What I want to do is to... get things from the library into an array using a string construction to find names. Names will be unique. Is that... what @elyaradine is describing? XD

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    EDIT:
    Also remember that if you ARE using editor scripting to change an object in your scene or a prefab in your project, make sure to call EditorUtility.SetDirty() on it or things will behave very very strangely indeed (values will appear to change but updates will not be committed).
    Jeez, the number of times I've forgotten this one!

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    Hello hello :)

    A quick one, I haven't found anyone with even the same problem on Google, let alone a solution :/

    I use a lot of TextMeshes for my UI because, well, it seems the easiest.

    Sometimes - often - but not always - when I type text into a TextMesh so that it says thing x, it looks like that in Editor. Then when I start the game, the same text turns into that placeholder bunch of random character material texture. Without fail. If I change the text during play, viola, it's back to what it's supposed to be, then when I stop and play again, it happens again.

    It's not ALWAYS the case, some textures are fine.

    The only solution I have been able to find is to always update the text at runtime, but that takes a long time if I have a bunch of stuff on screen, so was wondering if anyone has run into this and if there's a solution for it???

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    Hey,

    So I have a quick (and Im sure, stupid) question :P

    I am trying to get the cursor position in world coordinates. Now I know how to do this with the camer.ScreenToWorldCoordinates, but on the game object I am using it says that there is no camera attached?

    Not sure if this has anything to do with it, but I am using a 2D object.

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    Are you referencing the camera via Camera.main?

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    Tuism said:
    Are you referencing the camera via Camera.main?
    Yep. Still says that the GameObject has no camera attached.

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    I just threw together this in a new scene and it worked:

    if (Input.GetMouseButtonDown(0))
    		{
    			Vector3 p = Camera.main.ScreenToWorldPoint(new Vector3(100, 100, Camera.main.nearClipPlane));
    			Debug.Log (p);
    		}


    When I had "camera" instead of "Camera.main" it threw the error you were talking about. So.... That should be the problem.

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    [quote="Tuism;27502"]I just threw together this in a new scene and it worked:

    if (Input.GetMouseButtonDown(0))
    		{
    			Vector3 p = Camera.main.ScreenToWorldPoint(new Vector3(100, 100, Camera.main.nearClipPlane));
    			Debug.Log (p);
    		}


    Im not by my PC now, but I think I know what the issue is! I blame it on 2am coding :P I think I was saying gameObject.Camera, which of course wouldnt have a camera :P

    Thanks :D

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    CiNiMoD said:
    I am trying to get the cursor position in world coordinates. Now I know how to do this with the camer.ScreenToWorldCoordinates, but on the game object I am using it says that there is no camera attached?
    The Component.camera property is really just shorthand for GetComponent<Camera>(). This is the case for all the other shortcuts such as Component.transform, Component.renderer, Component.collider etc.

    Your camera property is looking for a Camera component attached to the same GameObject, that's why you're getting that error.

    @Tuism's solution should work provided your Camera component is on an object that has the "MainCamera" tag. Otherwise you will need to get some reference to the Camera component you want to use for your calculation.

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    Wait what? I thought Camera.main is just always automatically the main camera, am I wrong?

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    @Tuism: And how does Unity know which camera is the main camera? It looks for objects tagged with "MainCamera". Unity gives you such an object whenever you create a new scene, so you've probably never even noticed the tag.

    http://docs.unity3d.com/ScriptReference/Camera-main.html

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281

    Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    edited
    So the camera field on any MonoBehaviour script points to a SPECIFIC camera that's attached to the same object that the script is on, not necessarily the camera that's rendering the game (since there could be many).

    Generally, you have a camera tagged as MainCamera in the editor (the default one should have it on for you). As @Tuism mentions above, you can access that specific camera with Camera.main.

    That said, though, camera.ScreenToWorldCoordinates may not necessarily do what you want, even for a 2D game. A point on the screen is actually a whole ray in world space, so you might need to raycast using that point to get a world space position that's meaningful to you, especially if Z is important in your game. In 3D, ScreenToWorldCoordinate is almost useless, and casting rays is really the only way to get something worthwhile.

    EDIT: Eep, this is what I get for not checking if I'm on the last page of the thread. Squid's pretty much covered everything, ignore me.

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    So I've got another stupid question :P

    I am trying to shoot a projectile towards the cursor from the character. I am doing this like this:

    Vector3 cursorPos = Camera.main.WorldToScreenPoint(Input.mousePosition);
    Vector2 direction = new Vector2(cursorPos.x, cursorPos.y) - gameObject.transform.position;
    direction.Normalize();


    Im pretty sure thats how you're supposed to do it, although Im no Unity expert, and Im not sure getting the cursor position is right, or am I missing something completely stupid here?

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    @CiNiMoD: Shouldn't you be using ScreenToWorldCoordinates instead?

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    dislekcia said:
    @CiNiMoD: Shouldn't you be using ScreenToWorldCoordinates instead?
    Sorry, typo, thats what I am doing and its not working :/

  • Notice: Undefined variable: GuestHourOffset in /home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php on line 281
    Hey guys,

    So I've been playing around with Unity and things have been going OK. My little prototype is kinda getting there, but I have one issue. I cant understand how this flipping camera works :P

    I come from an HTML5 background where we are expected to make things "responsive". Its fine because we can just position things by absolute values, or percentages if we want them to scale. Lets say for example that I have a game that I want to be 960x540, then a background that will just fill the current view, how can I achieve this in Unity.

    I am using a 2D scene.

    Thanks,
    Dom
Sign In or Register to comment.

Debug Trace

Info Need to re-index theme cache
Info Need to re-index plugin cache
Info CommentModel->PageWhere()
Info
Comment.Page.30.1339.14: false
Info CommentModel->CachePageWhere()
Info
Comment.Page.30.1339.14: array (
  0 => '2014-08-17 16:28:13',
)
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/library/core/functions.render.php line 338.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 715.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/library/core/functions.render.php line 338.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 715.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.
Notice Undefined variable: GuestHourOffset
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 281.
/home/nitrogen/public_html_mgsatest/forums/library/core/class.format.php line 465.
/home/nitrogen/public_html_mgsatest/forums/themes/mgsa/class.mgsathemehooks.php line 712.
/home/nitrogen/public_html_mgsatest/forums/applications/vanilla/views/discussion/comments.php line 19.