Simple Character Movement

im new to this scipting part
but i really need a simple script for my charater
the only thing that he shall do is to walk forward and backward and jump
and if you have a camera to that i could also use that :wink:
hope you guys will help

Nobody is going to write your scripts for you. You’ll need to do your own research and ask specific questions on parts of your script you might be having problems with.

Take a look at the FPS tutorial and go through it from start to end and learn and understand how everything was done there, and then apply what you learnt to your project. It always helps to understand whats going on, you’ll never learn if people just ‘give’ you scripts.

Good luck :stuck_out_tongue:

Unity ships with a basic set of controllers in it’s ‘Standard Assets’ which you can import and get going with quite quickly. If you’re like me, you might find it handy to reverse engineer these and gain a lot more from the experience than just plonking them in : )

The best way is to use the First Person Controller asset built into Unity. But here is the SIMPLEST script option to at least teach you the minimal scripting part of it for now. I won’t get advanced at all. Just attach this script to a box. Make that box a rigidbody. Attach the main camera to the box. Set the player_jump variable in the inspector. int means intriguer, which mean a number without a decimal(1, 2, 3, etc…) float means a number with a decimal (1.0, 2.000, 3.04848648, etc…) This script will make you walk forward / back, sideways with the horizontal and vertical axes (w,a,s,d), or arrow keys, and jump with the spacebar. Set gravity in edit / project settings / physics. when I do anything like (0,0,0), this is the axes (x,y,z). Whatever I put in these instances adds a value to those axes :slight_smile: Like (0, player_jump, 0) in the script means 0 on x axis, player_jump value on y, and 0 on z.

var player_jump : int;
var walk_speed : float;

function Update()
transform.Translate(Input.GetAxis(“Horizontal”) * walk_speed, 0,
Input.GetAxis(“Vertical”) * walk_speed);

rigidbody.AddForce (0, player_jump, 0);