Hi everybody,
just trying some 3D out and wanted to ask for a better movement-script.
Right now I’m using this kind of movement method
float Horizontal = Input.GetAxisRaw ("Horizontal");
if (Horizontal >0)
{
transform.Translate(Vector3.right * WalkSpeed * Time.deltaTime);
}
[...]
But this becomes a problem, eversince I also built in a script to rotate the camera.
(Dunno if the camera script is important, but I’m pasting it anyways):
CamTurnL = Input.GetButton ("CameraLeft");
cam.transform.position = new Vector3 (player.position.x, player.position.y, player.position.z);
cam.transform.Translate(new Vector3(0,4,-15));
if (CamTurnL)
{
cam.transform.Rotate(Vector3.up * Time.deltaTime * camrotspd, Space.World);
}
So the problem of course is, that my “player” still moves along the world axis.
So, is it possible to somehow make a vector to the camera?
So that I always move forward when pressing “up”, no matter which camera position.