Hi
I have been searching everywhere for an answer to this but i just cant get any of the code suggestions to work as i am an absolute beginner and im just getting my head round things in order to start developing for android and cardboard.
I have a code from a tutorial for movement which is below but need help finalizing it by getting it to move in the direction of the camera
please could someone fix the code or explain to me how to fix it as ive been following several tutorials and tried the prefabs that all break in android.
Heres the code:
[code ]
public class PlayerController : MonoBehaviour {
public float speed = 6.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;
public CharacterController controller;
void Start(){
// Store reference to attached component
controller = GetComponent();
}
void Update()
{
// Character is on ground (built-in functionality of Character Controller)
if (controller.isGrounded)
{
// Use input up and down for direction, multiplied by speed
moveDirection = new Vector3(Input.GetAxis(âHorizontalâ), 0, Input.GetAxis(âVerticalâ));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
}
// Apply gravity manually.
moveDirection.y -= gravity * Time.deltaTime;
// Move Character Controller
controller.Move(moveDirection * Time.deltaTime);
}
}
[/code ]
any help will be greatly appreciated