#unitytutorial #unitymove #unitymovegameobject #unitymoveobject
I play games here - / zzotoff
You are very welcome :-)
Hello everyone!
In this video I will show you how to move a game object with arrow keys in Unity game. Here we have an empty project with a simple model of a ball which you can get from open gem art site. Here is a set of 3d objects which contains this ball. I’ll put a link to this asset into the description. Big thanks to the Ouren for this asset. Ok. Let’s quickly set up our project. First of all I create a floor for our ball. Create - 3D object - Plane. Here it is. Reset it’s position. And scale it down a bit. Here we go.
Next game object here will be a ball. I just D&D it into the hierarchy and bring it up like that. Our ball needs a couple of components. First one is a Rigidbody. And the second one is a sphere collider. Ok. Focus on the ball by double click. Collider is a bit too big and positioned not quite properly. Let’s fix it. I set center point position and radius. Almost there. Ok. Looking good for me. Now let’s put our main camera into proper position. Select it. I already know in what position I want camera to be so I set it here in inspector. And also I give the camera some rotation in X axis so game view will show us our playground this way.
Ok. To move our ball we will use a script named Move. Let’s take a look at it. It’s very simple. First we have a rigidbody reference to control it’s velocity. Then we have moveSpeed variable, dirX and dirZ variables that will help us to move our ball. In start method we set moveSpeed to 3 and get control over that rigidbody component. In update method we assign dirX and dirZ variables depending on which arrow button is pressed. So if we press left or right button then dirX becomes equal to negative one or positive one multiplied by moveSpeed. And if we press up or down button then dirZ becomes equal to negative one or positive one multiplied by moveSpeed. And in fixed update we pass a velocity to rigidbody by X and Z axis according to dirX and dirZ values. Velocity by Y axes stays the same. That’s the script. D&D this script to Ball game object.
That’s it. Now we can hit play and see how it works. I press left, right, up or down buttons and the ball moves according to that input. Hope this tutorial was useful for you. Thank you for watching. See you next time.
If you like what I'm doing then you can support me through
www.patreon.com/alexanderzotov
or here
https://www.paypal.me/AZotov
Thank you)
Basketball Set https://opengameart.org/content/baske...
What this video is about and what it can be used for also: unity 2d tutorial,
unity tutorial, unity game, unity 3d, How To Move A Game Object With Arrow Keys In A Game Made With Unity Software, Simple Move a Game Object with the Arrow Keys, unity move game object, unity move gameobject, unity move character, unity move arrow keys,unity movement, unity movement 3d, unity move object, unity move player with arrow keys, unity arrow keys movement, unity simple move, unity simple tutorial, unity beginner, unity beginner tutorial, learn unity fast, unity tutorial, how to make games with unity, unity how to make game, unity how to make 2d game, not as good as brackeys but good as well, unity player movement, how to make the ball move left and right before hit it in unity, how to make the bowling ball move left and right before hit it in unity, how to move object in unity using buttons, how use left and right arrow keys unity, unity 2d or 3d arrow movement tutorial, unity how to move a sphere, unity how to move a ball.
Информация по комментариям в разработке