Hello everyone! So im designing a game where i need to use a rigidbody caracter, because i want him to be able to walk on walls or cellings using costum gravity. I want a good old fashioned 8 Direction control i tought thats the best for my game. It will be a 3D platformer where the player needs to jump on small moving objects to proceed trough the level, so it needs to be precise.
First i tried to move my player with AddForce but it isnt the way i want it because with AddForce the character first accelerates then deaccelerates which is bad because i cant move it on small surfaces. Then i tried with velocity change and it works because the player starts with full speed and almost stops immedatelly but then i encountered a problem : when i jump and want to controll the player its works fine but when the character starts to fall down the falling speed suddenly really slow and not realistic. if i jump and dont move evrithing is fine, but in midair controll the problem apears. Is somebody who is more experienced with a rigidbody character can help me out? Its driving me crazy for the past three days. Here is my code:
var direction : Vector3;
function FixedUpdate ()
{
var h : float = Input.GetAxis("Horizontal");
var v : float = Input.GetAxis("Vertical");
direction = Vector3(h,0,v);
if(Input.GetAxis("Horizontal") || Input.GetAxis("Vertical"))
{
rigidbody.velocity = direction * 10;
}
else
{
rigidbody.Addforce(Vector3.up * -10); //adding Gravity
}
if(Input.GetButton("Jump"))
{
rigidbody.velocity = Vector3.up * 20;
}
}
Thanks in Advice!