Harder than it looks! I tried using rotation. (transform.rotate) but I want it to have a force when it moves. If I use transform.rotate, it looks unrealistic and instantly rotates to the designated vector. I want it to move to that rotation, not instantly. So I thought using angularVelocity of Rigidbody component would work for this. This code isn’t working too well. When I play the game and press the AD keys, I barely see it turn at all. And if it does turn, it sure isn’t smooth.
There’s an icon next to the disk while you’re writing forum posts, it’s labeled insert, put your code inside the insert code bit so it’s a bit more legible/familiar to read online.
I’m making a cube game in 3D space. What this code is supposed to do is if you hold down the A or D keys it will constantly rotate the cube in the according direction. To my surprise, the Y coordinate actually acts like the X, or maybe the Z. It’s hard to know in 3D space! Must have it positioned in a weird way. I’ll uncheck gravity, set it to 200, and try again.
It’s nicer on the eyes reading it, I had to copy and paste into mono, you can’t visually debug something that fast without proper formatting however simple it may be. It’s usually the simple stuff that gets you like only chucking one variable into control a three dimensional point in space.
Look into the Vector3’s of both angular velocity and rotation, at moment you’re rotation round the Y and adding force only in the X, experiment chucking Velocity into all of this bit (new Vector3(Velocity,Velocity,Velocity) for instance and same for rotation maybe.
I’m back. So everything works, but why can I not change the speed of the velocity? … Also I don’t know how you format code. I’m looking for it, I clicked on use BB code editor, but nothing is happening.
To format the code while your writing the message click the button called insert, box with a little I in it, when you click it there’s an option for code, and just pop it in there.
I’m just trying to write a better version of your code, hang on two secs
I’m not entirely sure but I think that Input.GetAxis is a bit more versatile in certain situations as it allows you to control with your arrow keys as well as ASDW
I guess one way to look at the Axis part is instead of specifying every direction individually ie up, down,left,right, front, back, you can simplify the process by giving each pair an axis, look at the gimbal the basic 3D pointer is three axis, simplifies into x,y,z and you can have negative and positive numbers to describe the difference between front and back on just a line.
Reach your hands out that’s your horizontal axis, -1 would be either left and +1 would be right, you can do the same thing with vertical, up and down your waste is 0, your toes are -1 and your head is +1 for example