This is my first post, so first of all, hello everyone. (sorry if this post is in the wrong place)
I’ve just discovered unity, and have decided to try my hand at creating a game, with the aim of learning as I go. I’m going for a basic space flight racing type game (fly through the rings in order type thing). I’m trying to start by creating a spacecraft and making it fly around. trying to adapt the 3rd person shooter tutorial, I have created a capsule and attached a camera to it in first person mode, and as expected I have hit a road block, in that I don’t know how to make it fly around in the direction the user is facing.
My question is - where do I go from here. Should I break off from unity and try and learn C# outright, or can I “learn as I go” and try to adapt the first person script? I do understand the basic principals of programming, and can write php quite well, its only the specifics of the language I’m not familiar with.
Alternatively, is trying to do the movement scripting a bad place to start? Should I be looking elsewhere to start with?
Ok, so decided to have a stab at this. I’ve followed the fps tutorial to the point of having a regular FPS character that can walk around as normal on the ground, then I’ve opened up FPSWalker.js and started fiddling.
var speed = 6.0;
private var moveDirection = Vector3.zero;
private var grounded : boolean = false;
function FixedUpdate() {
if (Input.GetButton ("Fire1")) {
moveDirection = Vector3(Input.GetAxis("Mouse x"), Input.GetAxis("Mouse y"), Input.GetAxis("Mouse z"));
}
// Comment applying gravity as we don't want any
//moveDirection.y -= gravity * Time.deltaTime;
// Move the controller
var controller : CharacterController = GetComponent(CharacterController);
var flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags CollisionFlags.CollidedBelow) != 0;
}
@script RequireComponent(CharacterController)
The idea is that whenever Fire1 is pressed (Left ctrl in this case) the character will move in whatever direction the character is facing.
Now, this dosen’t work and I’m sure I’m making a total newbie mistake, but I don’t know whats wrong with this. If I run this, the character can look around, but does not move.
Can someone suggest where I’m going wrong. I’m guessing I’ve misunderstood what 1 or more functions do, but I’m not sure which.
I’ve realized this is really more of a scripting question than anything else, so I’m going to create a new thread there - Could a Mod close or delete this please?