I have game where I have a rigid body cylinder on a terrain. I have the Main Camera in mouse orbit with the cylinder, (using the MouseOrbit.js with cylinder as target). I also added a script so when the ‘W’ key is pressed, the cylinder moves in one direction.
#pragma strict
var speed : float;
var target : GameObject;
function Start () {
}
function Update () {
if (Input.GetKey(KeyCode.W)){
transform.Translate(-Vector3.forward*speed*Input.GetAxis("Vertical"));
}
}
What do I add to make the cylinder’s direction change with the camera’s direction so that the forward direction is pointing away from the camera. So basically it’s like a third person control.
So basically it needs to be like a third person player when ‘W’ is pressed, the cylinder needs to move away from the camera and the mouse changes the direction.
Thanks in advance.