Search Unity

Instatiate an object with force not working?

Discussion in 'Scripting' started by DaveyJJ, Jun 10, 2007.

  1. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    I'm trying to use the standard "instantiate an object and project it forwards" script (in the exact direction the camera is facing) but it's kicking it out 90 degrees to the left instead? Anyone else seen this?

    I have my camera with mouselook.js attached to a FPS object and want the game object to spawn just under the camera and shoot in exactly the direction the camera/player is looking. No raycast to object involved as it needs to just shoot regardless if there's anything to hit.

    90 degrees left ... weird.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Sounds like the object's forward axis is 90 degrees off compared to the camera's forward axis. Or is that script attached to the camera? Either make sure the axes of the objects are all oriented the same, or you could just change the script to use a different axis. But I'd say making sure the objects are physically correct is better because you never know what else might go wrong.

    --Eric
     
  3. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    It's attached to the camera. But I sort of figured it out. It's shooting a ball where the cursor is on the screen, not where the camera is looking.

    Fixed it by locking and hiding cursor. Also found the set screen resolution line of script ... nice. :)