I would like to know how to make my camera move and rotate in z,x and y axels so i can use it in a space game. The first person Controller and 3rd person controller only move in one level, because they are designed for a game with floors. Can some1 plz help me?
I think you want something like this:
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public GameObject camera;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey("space"))
{
camera.transform.Translate(new Vector3(0, 10, 0));
}
}
}
That will move the camera up in the y axis, when you press down the space bar.
transoform.rotate (may also work) of couse you would still need to program the buttons and appy a force to move foward .
you can add constant force to move in which ever direction you are currently in.
The above code can be used to change the values of x, y and the z axis (by applying different values to the axis you want to alter.
The cursor keys could be set up for up and down movement and turning to the left and to the right. (stafling or side movements for when fighting could be applied to the v and b buttons as its near the space bar which could be used for moving fowards or shooting.
To move forwards (the z axis is often used)
Go to unity script refrence
Look at rigid body.apply realative force. Transform.translate Rotate.
To have utter control over a space ship you need to think about what do i actually want it to do (do i want my camera to rotate downwards when the player presses the down key , do i want the camerea to roatate in the air while climbing.
When roatating to move left and right how would apply this motion when using 2 buttons. what button do i need to make it move fowards . Do i need it to be able to reverse.
Hope this helps