Hey all,
So the title is a bit vague, but let me go ahead and elaborate. First off I don't have much experience w/ code. I have used C++ in the past and am learning javascript atm. I know most basics of programming but struggle w/ finding a starting point and logic.
I have finished a simple tutorial series on Digital Tutors that got me a decent understanding how how to script in Unity and I have created a simple movement script. What I am trying to do now is refine the camera to be more "smooth". I would like the camera to smoothly lead ahead of the character when moving in that direction (Though it doesn't have to be exactly as I described). A similar camera system that I found is in this link for the recently released game "Swapper".
[url]http://www.youtube.com/watch?v=MHABt6fRo7U[/url]
So enough of my rambling. I was hoping to get some hints or some possible ways that this effect could be done. I would very much like to figure the code out on my own. I will link my movement script below.
[CODE]
var speed : float = 6.0;
var jumpSpeed : float = 6.0;
var gravity : float = 12.0;
//This variable is now inheriting the Vector3 info (X,Y,Z) and setting them to 0.
private var moveDirection : Vector3 = Vector3.zero;
function MoveAndJump() {
var controller : CharacterController = GetComponent(CharacterController);
if(controller.isGrounded) {
//moveDirection is inheriting Vector3 info. This now sets the X and Z coords to receive the input set to "Horizontal" and "Vertical"
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); //Allows player Input
moveDirection = transform.TransformDirection(moveDirection); //How to move
moveDirection *= speed; //How fast to move
if(Input.GetButton("Jump")) {
moveDirection.y = jumpSpeed;
}
}
//Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
//This moves the controller
controller.Move(moveDirection * Time.deltaTime);
}
function Update() {
MoveAndJump();
}
[/CODE]
Thank you!
↧