- Home /
Object looking straight down when jumping
So my new problem is that when I have my make shift barrel/gun right now looking at the mouse in a 2d world. The barrel and the rest of the gun are a child of an empty gameobject located in the center of the player, and this gameobject is itself a child to the Player. This works perfectly, until I jump. When I jump, the barrel moves up slightly, and then rotates and looks down until you land and move your mouse again. After you move when you hit the ground, it snaps back to looking at the mouse. Here's my LookAt script, very basic:
function Update () {
transform.LookAt(PlayerScript.hitPoint);
transform.Rotate(0,-90,0);
}
Any help would be greatly appreciated. It's probably an easy fix that I'm just looking over.
EDIT: The LookAt script is attached to the empty GameObject which is a child of the player.
Which child is this script attached to? Is it your root parent?
Anybody please help? It's annoying me cause right at the beginning of the level you fall down and I just want the gun to always look at the mouse cursor no matter what. Any help is most appreciated.
Is this your entire script? Are there more attached to your player?
The only part of this that is attached to the player is where I find the mouse potion (hitpoint), but I see no error with that code. This is all of my lookAt code. If you need any code, ask and I'll edit the question to provide you with it.