FPSController - Smooth Movement
Hi there, just wondering if anybody could help me.
I'm using the FPSController from the Unity Standard Assets. While it does pretty much everything I want it to, I'm finding the movement to be a little too sudden and sharp. (full speed or completely stationary)
I would like the walking/running to be a little smoother (some slight acceleration/deceleration.)
Would anybody have any ideas on how I could modify the code to allow for this? I haven't been able to find any solutions online.
Thanks a lot guys!
Post the moving code if want some help... dont think? ;D
Oh, my apologies! I assumed that people would be familiar with this code since it's from the FPSController in the standard assets, but I'll post it here nonetheless!
[code] private void FixedUpdate() { float speed; GetInput(out speed); // always move along the camera forward as it is the direction that it being aimed at Vector3 desired$$anonymous$$ove = transform.forward*m_Input.y + transform.right*m_Input.x;
// get a normal for the surface that is being touched to move along it
RaycastHit hitInfo;
Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo,
m_CharacterController.height/2f, Physics.AllLayers, QueryTriggerInteraction.Ignore);
desired$$anonymous$$ove = Vector3.ProjectOnPlane(desired$$anonymous$$ove, hitInfo.normal).normalized;
m_$$anonymous$$oveDir.x = desired$$anonymous$$ove.x*speed;
m_$$anonymous$$oveDir.z = desired$$anonymous$$ove.z*speed;
if (m_CharacterController.isGrounded)
{
m_$$anonymous$$oveDir.y = -m_StickToGroundForce;
/*
if (m_Jump)
{
m_$$anonymous$$oveDir.y = m_JumpSpeed;
PlayJumpSound();
m_Jump = false;
m_Jumping = true;
}
*/
}
else
{
m_$$anonymous$$oveDir += Physics.gravity*m_Gravity$$anonymous$$ultiplier*Time.fixedDeltaTime;
}
m_CollisionFlags = m_CharacterController.$$anonymous$$ove(m_$$anonymous$$oveDir*Time.fixedDeltaTime);
ProgressStepCycle(speed);
UpdateCameraPosition(speed);
m_$$anonymous$$ouseLook.UpdateCursorLock();
}
[/code]
As this code references a lot of other scripts, I didn't post ALL of it here, but let me know if you want to see the rest!
Thanks again!
Okay new problem: I have no idea how to post code on this forum haha. None of the codeblock markdown I've found online works!
Your answer
Follow this Question
Related Questions
having CharacterController movement in fixedupdate causes jerky movement on camera 3 Answers
Terrain Problem! Character begins to wobble extremely! 2 Answers
How to have your player controls change while your camera rotates? 0 Answers
Issue with getting the mouse position in 3D and moving a gameobject on the y & z axis 0 Answers
Can I ignore part of a vector3 for physics reasons? 0 Answers