Is there no built in way to enable air control on the character when in the air, like during a jump, the character goes perfectly straight and doesnt allow input to steer it in midair?
Its not very realistic but absolutely a must for jumping puzzles D;
Has anyone figured out how to cleanly achieve mid air control?
yeah it works by adjusting air acceleration, but doesnt let you increase it more than a little unless you want to go supersonic speed while in the air, which is not wantedā¦ so you only have a little air controlā¦
Itās really up to how you configure the character controller. The general way I do it involves checking to see if youāre on stable ground, and if so, allow movement. But if I donāt do that check, and just always allow the player to control their velocity, then that allows them to control the character in air.
Make sure you go through the included tutorials so you understand how all the functions work. This isnāt really a character controller to be used just out-of-box, youāre expected to have some experience coding to create a character controller to your liking. The system handles a lot under the hood, but velocity is not controlled for you, you move the character however you want in the controller through the character motor, and it handles the rest for you
Iām posting this in case anyone else runs into this issue. In my game I found that a bug was introduced after updating to the latest version of KinematicCharacterController. I stop my moving platforms by setting enabled to false on the PhysicsMover component (is that the wrong way to do it?). This unregisters the physics mover and stops the platformās position from being updated. What I found with the latest version is that my character will drift if it stands on the platform after it has been stopped. I resolved this by setting Velocity and AngularVelocity to zero in PhysicsMover.OnDisable().
private void OnDisable()
{
// begin bug fix
Velocity = Vector3.zero;
AngularVelocity = Vector3.zero;
// end bug fix
KinematicCharacterSystem.UnregisterPhysicsMover(this);
}
One thing I have noticed after the update to the latest version, is that when I go up a small incline my character launches like a vehicle driving off of a ramp. My game is a first person shooter so this is not appropriate. Has anyone else noticed this?
Update: I fixed it by increasing āMax Stable Slope Angleā
this controller is very, very good but can anyone tell me a good way to remove all of the interpolation/smoothing from camera and player rotation for the sake of a first person shooter, i feel like i have bypassed 10 slerp functions related to it but there is allways some left
Very simple question, how to prevent the KCC from pushing any Rigidbody ? Setting RigidbodyInteractionType to None doesnāt change anything.
I also removed this line :
bodyHit.Rigidbody.AddForceAtPosition(velocityChangeOnBody, bodyHit.HitPoint, ForceMode.VelocityChange);
but it doesnāt have any effect. Rigidbodies are still getting pushed.
If an object has a collider at all, youāll push rigidbodies, thatās just how the physics engine works. You can set up the collision layers to prevent certain objects from being touched by your player, but your player in turn wonāt be able to bump against them.
If you donāt want a certain object to be pushed at all, either remove the rigidbody or mark the rigidbody as kinematic. Kinematic just basically equates to āthis thing wonāt be effected by other forces in the physics engineā
Hey, Iām trying to create a lock on movement around target (character should always rotate around target, including when in air/jumping). something similar to Darksiderās 2 lock on movement.
does anyone have any idea how to achieve it with KCC?
Iāve managed to get it working for ground movement, however Iām having trouble maintaining orbit speed when player is jumping and adding the ground smoothing factor for movement.
hereās what I have so far (code is mostly based on tutorial scripts in package):
// called in UpdateVelocity when motor.GroundingStatus.IsStableOnGround = true
private void UpdateGroundVelocity(ref Vector3 currentVelocity, float deltaTime)
{
// Reorient source velocity on current ground slope (this is because we don't want our smoothing to cause any velocity losses in slope changes)
currentVelocity = motor.GetDirectionTangentToSurface(currentVelocity, motor.GroundingStatus.GroundNormal) *
currentVelocity.magnitude;
// Calculate target velocity
var targetMovementVelocity = GetGroundOrbitVelocity(deltaTime);
// Smooth movement Velocity
// TODO: fix velocity smoothing
currentVelocity = targetMovementVelocity;
// currentVelocity = Vector3.Lerp(currentVelocity, targetMovementVelocity,
// 1 - Mathf.Exp(-groundMovementSharpness * deltaTime));
}
private Vector3 GetGroundOrbitVelocity(float deltaTime)
{
// if no left/right input or if there's forward/backward input
// then "break" orbit movement and use standard orientation movement
if (Mathf.Abs(_initialInputVector.y) > 0 || _initialInputVector.x == 0)
{
var inputRight = Vector3.Cross(_moveInputVector, motor.CharacterUp);
var reorientedInput = Vector3.Cross(motor.GroundingStatus.GroundNormal, inputRight).normalized *
_moveInputVector.magnitude;
var targetMovementVelocity = reorientedInput * groundMoveSpeed;
return targetMovementVelocity;
}
UpdateOrbitHelperPosition(deltaTime, groundMoveSpeed);
var velocityForMovePosition =
motor.GetVelocityForMovePosition(motor.TransientPosition, orbitHelper.position, deltaTime);
return velocityForMovePosition;
}
// using a transform helper to calculate RotateAround correctly
private void UpdateOrbitHelperPosition(float deltaTime, float moveSpeed)
{
orbitHelper.position = motor.TransientPosition;
var lockOnPosition = lockOnTransform.position;
var distanceToOrbit = Vector3.Distance(motor.TransientPosition, lockOnPosition);
var angle = 2 * Mathf.Asin(0.5f * moveSpeed * _initialInputVector.x * deltaTime / distanceToOrbit) *
Mathf.Rad2Deg;
// character up need to change if planet gravity is not straight up
orbitHelper.RotateAround(lockOnPosition, motor.CharacterUp, -angle);
}
if anyone knows how i can get it working in air and add smoothing to movement
Hi everybody. Iām currently working on creating a FPS character movement with this KCC and having a hard time implementing the separate speeds for walking forward and walking strafe based on the ExampleCharacterController. Here are the SetInputs function which takes in the userās wasd input and the UpdateVelocity function at the moment.
It would mean a lot to me if anyone could help me figure this out!
Thank you in advance!
I did it! I have successfully implemented the feature above so hereās how to do it, in case you need to know!
I changed the lines that are highlighted with selection for SetInputs and UpdateVelocity functions.
What I did was multiply strafe and forward speed to the input rather than to reorientedInput. And because the _moveInputVector is no longer a normalized Vector3, in order for the air movement to stay consistent across the original code and the new code, I normalized the _moveInputVector which is multiplied by AirAccelerationSpeed * deltaTime in the else that handles the air movement.
Does any1 had problem with KCC with rootmotion and cinemachine freelook? For me itās jitter a lot doesnt matter if i set interpolation, different update types etc.
Even on rootmotion example (Minimum replication project), if i add cinemachine brain + cinemachine freelook camera, the example jitters a lot.
Hi, Iām using this character controller and I really love it so far but Iām confused on how to make a mancannon to throw my character. Rigidbody.addforce doesnāt seem to do anything, neither does setting rigidbody velocity. I assume thatās because the KCC is dictating all this kind of stuff?
Iād like to throw my character across the map when he steps on a trigger, how do I do that with your controller?
Great package! Iām currently using it in my project, and itās working really well overall. However, Iām encountering an issue when implementing multiplayer. While the first player can push rigidbodies as expected, the second player seems unable to interact with or push them.
Has anyone else encountered this problem in a multiplayer setup? Any ideas on what might be causing this, or suggestions for how to resolve it?