Controlling Character Speed via a Public Variable?
I'm creating a 2.5D Platformer, and I'm relatively new to Unity. One of the main issues I've had is manipulating rigidbodies. What I'm trying to do is have it so that the players position is based on a variable.
Here's how it'd work in other languages I've used:
-Every Tick,
Set XPosition("Player" ) to XPosition("Player") + XSpeed("PlayerValueHolder")
The stuff in the parenthesis is the object, and the variable outside it belongs to that object. XPosition is a built in variable, and XSpeed is a user-defined one. With this code, the player object will move at a speed of 6 when XSpeed is 6. Obviously. When coding this way, this is exactly how fast Sonic the Hedgehog moves at his top speed when slopes are not in effect, regardless of the game engine, as long as the framerate is 60. This is what I'm going for.
Any ideas on how to do this? The methods I've tried so far have proved futile. I can move the rigidbody around all I want using all the different methods, but being able to control it via a separate variable has proven tricky.
Any help is appreciated. Thanks in advance!