Okay I'm not going to go to much into it but this is what I need my script to do. The way I have my controller set up is that the camera looks to the side of the player a little bit. I use this for aiming attacks, bullets and what not. The problem is that it follow the camera when it looks up causing my character to slightly jump ever time I aim and look up. So i want the player to move with the camera while ignoring its y axis. and i need my character to jump so i cant just make the players y movement = 0.

Here's the code I've been using:

transform.position += Time.deltaTime * cameraMain.forward * Input.GetAxis("Vertical") * speedWilAim;

and I am trying to avoid separating the mouse look script into x and y pivots but if there is no alternative I will do that.

  • \$\begingroup\$ What exactly is the problem? There is an up movement of your character because of the position of the camera? \$\endgroup\$ Aug 4 '15 at 18:38
  • \$\begingroup\$ well when you look up with the camera and move forward the character goes up. I just want my character to go forwards not upwards \$\endgroup\$
    – Ryan Henry
    Aug 4 '15 at 19:03
  • \$\begingroup\$ Is your camera parented to the player? \$\endgroup\$ Aug 4 '15 at 19:04
  • \$\begingroup\$ nope its on a rig that follows the player and im using the third person controller so that wouldnt work out im modifying it \$\endgroup\$
    – Ryan Henry
    Aug 4 '15 at 19:07
  • \$\begingroup\$ You could try separating the camera and write a script for the camera alone to follow the player. \$\endgroup\$ Aug 4 '15 at 20:30

Okay I went ahead and separated my mouse look function which I used to rotate my camera rig, into the X and Y axis and placed them on two different objects. The one with the x axis was used to dictate how what direction my character moves.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.