Amateur question about movement

Hey guys,

I have my player, which is the camera, and I’ve programmed to rotate with the mouse and I need to program its forward movement. I read that Vector3.forward is just shorthand for Vector3(0,0,1). Which should I use and why? If I had to take a guess on using the latter than it would be so I could plug in a variable where the 1 is?

You probably want transform.forward if you want the object to move ahead according to its local rotation. Vector3.forward would move it relative to the world.

Try this:

transform.position += transform.forward * speed * Time.deltaTime;

Thank you for the quick reply. I was really curious how it was going to move forward based on it’s rotation. I’m used to working with 2D Flash games using Actionscript 3.0 so working with a 3D environment is all new to me. I’ll give your code a whirl.

[QUOTE=“GroZZleR, post: 2206636, member: 763877”

transform.position += transform.forward * speed * Time.deltaTime;

[/QUOTE]
Since the player’s movement will rely on a key press I know I will need it in Update() but would there ever be a circumstance where I would control the player’s movement with FixedUpdate()?

A man after my own heart.

FixedUpdate is used for physics based movement, generally. So if you’re working with rigidbodies, that’s where you’d assign the velocity (rather than moving the transform as I did).

Thanks for your help dude. I’ll be sure to check out your games haha