unity3d: 1.Steerage

I will show you today how to make a simple steerage mean steerage on right, on left, directly and backword and jump, it all comes down to one script

Assign that script to for example cube this is the simpler solution which may be, this is only example, go to discuss the script.

On the top the script are variables type float, variable go is defining how fast object is moving, variable jump is defining how high object can jump, next is variable physics object, which it is adding physics to jumping, that will look like as a jump, now object won’t show up in one second in air and variable IfGround is needed to detecting position object.

In function “Start” We are downloading physics component and in function “Update” is a heart of the program, inside of condition if is instruction which will execute when player will enter left arrow, then object will move in left. In next line is adding position object and direction wherein object have to move and accumulate it throw variable go to define speed object. We have to accumulate all throw Time.deltatime, because if we won’t do that, object would have to agitate in different speed. Rest of the code do 26 line look like similar, is only different arrows and directions.

From 27 to 29 line code define when player will enter space and if object is on ground, then object have to jumping, and jumping object will to keep as physics object.

On the bottom the script there are two functions which are checking that object is in air or on ground, if weren’t those functions we would jump in air.

That’s all, we should compile and drag and drop script to object which you would to move.

If you would to like move character in 3d game making your own script so that’s no sense because you can download ready scripts control character, on the top in bookmark assets in Import package enter on Characters download all and find object „First person controller” and drag and drop it on scene and here we go, you have ready script control.

This content also you can find on steemit: https://steemit.com/steerage/@slawas/unity3d-1-steerage

And on medium: https://medium.com/@sawomirkowalski/unity3d-1-steerage-10eb3f5f5789

That’s all, thanks, see you later!

If that post was useful for you share it with your friends :)

Post a comment

Notify about