Ok. Im a noob so this is probably a stupid question.
I had a player movement code that looks like this:
var controller : CharacterController = GetComponent(CharacterController);
Grounded = 1 * ( controller.isGrounded ? 1 : 0);
// Apply gravity
if(Grounded == 0) {verticalSpeed -= gravity * Time.deltaTime;}
else {verticalSpeed = 0;}
ApplyAnimation(controller);
ApplyJump(controller);
// Rotate the controller
transform.Rotate(0, Input.GetAxis ("Mouse X") * rotateSpeed, 0);
// Move the controller
moveDirection = Vector3(Input.GetAxis("Horizontal") / 2 , 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
var movement = (moveDirection * moveSpeed) + Vector3(0, verticalSpeed, 0) ;
controller.Move(movement * Time.deltaTime);
And I put it into a multiplayer code:
function FixedUpdate()
{
//Only run this on the server
if(networkView.isMine)
{
<PLAYER MOVEMENT CODE GOES HERE>
}
}
But now gravity has stopped working. I find it works again if rather than putting:
if(Grounded == 0) {verticalSpeed -= grav * Time.deltaTime;}
I put:
if(Grounded == 0) {verticalSpeed -= grav;}
(Removing the deltaTime makes it work)
But I need delta time! Don’t I? To stop the gravity from being different at different frame rates. Other occurances of DeltaTime have worked… except this one doesnt.
I’m confused… ![]()
Also interestingly I cannot work with a value of gravity less than 1… maybe this is related…