Hello, I am a game designer who is trying to learn some scripting. However, I have no idea where to begin on this prototype of mine. You see, I have this rocket sitting in my scene which I want to control with a system similar to Asteriods. You know, rotate and thrust. But I just don't have any clue where to start. I understand the concepts behind programming languages, but I lack the experience to do this without some guidance.
Here is some information about the game, Liftoff:
The goal is to blast off from a planet's surface and escape its gravity well. It is played on vertical scrolling levels filled with obstacles. Think Asteroids with gravity on rails.
My main concern is getting the rocket manipulated by the keyboard the way I want. I'll worry about the rest of the game once I get the controls feeling right. Can anyone help me?
It is the component which controls all the physics stuff so you don't have to worry about it (very much).
And take a look at the Input Class which is the class from where you can get key presses and such stuff.
Now, an example:
If you want to move your rocket forward/backwards when you press the up/down (or w/s) keys you can do it like this:
var speed : float = 1;
//Run the code in fixed update to ensure stable physicsx
function FixedUpdate () {
//Get the input value, you can change the input keys in the Input Manager
var vert : float = Input.GetAxis ("Vertical");
//Add a force relative to the objects rotation (not the world)
rigidbody.AddRelativeForce (Vector3.forward * speed);
}