[ad_1]
Transient Description: I’ve a RB based mostly character controller that I need to transfer together with my Practice platform (non physics based mostly) when the participant steps on it.
Primary Downside
I handle to make the participant comply with the platform, however I even have a digital camera jitter downside that I can not resolve with out breaking participant comply with the Practice platform logic.
Video displaying the jitter.
Necessary: I am not getting any jitter when solely transferring the digital camera
Necessary: I am not getting any jitter when solely transferring the Character with out transferring the digital camera
this is applicable to each when the participant is on a transferring platform, or off the platform
https://www.youtube.com/watch?v=9M4dt00dEes
My Digital camera Implementation
For dealing with the digital camera I am utilizing Cinemachine, alongside a CameraHolder which is a separate gameobject from the participant.
I am setting the remodel of the cameraHolder Gameobject to the gamers place in late Replace
personal void LateUpdate()
{
remodel.place = cameraPosition.place;
}
The Headbob Offset gameobject is a baby within the cameraHolder with none motion.
Participant Controller Motion
I am utilizing this code in FixedUpdate to deal with my participant motion
personal void HandleMovement()
{
//previous enter system
//float horizontal = Enter.GetAxis("Horizontal");
//float vertical = Enter.GetAxis("Vertical");
//Vector2 movementDir = new Vector2(horizontal, vertical).normalized;
//New enter system
movementDir = GameInput.occasion.GetMovementVectorNormalised();
Vector3 currentVelocity = rb.velocity;
Vector3 targetVelocity = new Vector3(movementDir.x, 0, movementDir.y);
targetVelocity *= pace;
targetVelocity = remodel.TransformDirection(targetVelocity);
Vector3 velocityChange = targetVelocity - currentVelocity;
velocityChange = new Vector3(velocityChange.x, 0, velocityChange.z);
Vector3.ClampMagnitude(velocityChange, maxForce);
rb.AddForce(velocityChange, ForceMode.VelocityChange);
}
RB interpolation is about to Interpolate
Practice Platform Motion Script
personal void FixedUpdate()
{
remodel.place += remodel.ahead * currentSpeed * Time.deltaTime;
}
Necessary I am utilizing FixedUpdate, however my practice platform has no RB on it, I am utilizing FixedUpdate, as a result of in any other case my participant does not comply with the practice place change.
What I’ve Tried thus far
1. Lerping Digital camera Place
As an alternative of setting the digital camera place to the cameraHolder, I attempted lerping. It solved the general jitter within the recreation, however my entire practice platform turned jiterry when transferring.
personal void LateUpdate()
{
remodel.place = Vector3.Lerp(remodel.place, cameraPosition.place, lerpSpeed * Time.deltaTime);
}
Movies displaying the issue
jitter virtually solved https://www.youtube.com/watch?v=sxXXk_oVpsg
Practice jitter https://www.youtube.com/watch?v=85biDT_nl_4
2. Add dumping to Cinemachine digital digital camera
outcomes are the identical as with lerping. every part else is easy in addition to the practice
I am going to present any vital data if I have not talked about one thing right here
[ad_2]