How to keep FPS character on moving platform when it's not kinematic?

Sarr

New member
Hello, I have a problem keeping FPS character on moving platform when it's not kinematic.
Thing is, I can't set the platform (a vehicle) to kinematic, it must be fully rigidbody physics. When I added ability "Move with platform" and used the script "Kinematic Object", it worked (and ability was active), but my object that the character is standing on can't move anymore. It needs to be subject to outside forces, so not kinematic, and it's a part of a bigger system that I can't rewrite at this point.
So basically, I need character stable and standing on this object and just moving only relative to that object, fully sticking, without jitter, but with an ability to jump and collide with colliders. I've tested "Stick to Ground" but greater acceleration of the platform or it's fast rotation (or being upside down with the platform) drops the character off the platform. It's not spherical too, so I can't use spherical gravity.
How to fix that, is it possible with FPS controller?
 
The KinematicObject requires that the object is updated in FixedUpdate. Otherwise it will not move. Make also sure that the script execution order is correctly set:
 
The KinematicObject requires that the object is updated in FixedUpdate. Otherwise it will not move. Make also sure that the script execution order is correctly set:
I know, but the problem is my vehicle is a dynamic rigidbody. Can't make it kinematic because its whole movement is complex and made with dynamic physics. It's also flying and rotating. So far I've made a custom gravity zone (Align to Gravity Zone activates) that keeps the character on the vehicle even upside down. When vehicle is not moving it's ok, but if movement is slow the controller starts to lose contact and jitter. With higher acceleration, be it in any direction or rotating, character soon loses attachment to the floor and falls off. Same with Align to Ground.

So, I need to somehow make the character "not notice" that the vehicle is moving. I need it to perfectly stick and never fall of by itself (only via some trigger). But to still be able to move on its floor like it wasn't translating/rotating. That also means, I need to change the characters direction when that vehicle changes direction, fully synced, even if my character is jumping and mid-air. So, when I jump and vehicle brakes or reverses, I need the character to brake or reverse with it exactly as it does. With no momentums throwing the character to the sides or off but like it was static.

Doesn't matter if it's some hack or not. I tried parenting character to that dynamic rigidbody, but it doesn't work. UFPS insists on simulating physics. Thought I'd just compare position and rotation of the vehicle every frame with that of the character and update the character by that amount (character.MovePosition(vehicleDeltaPosition); character.MoveRotation(vehicleDeltaRotation)), but don't know where to do it in UFPS to not make it go crazy.
Could you point me where in scripts to affect UFPS chars movement to add that position/rotation to synchronize it with vehicle? Not sure also if I should do this before UFPS processes its movement, or after.
It's not meant to be realistic, just synced 100% with vehicles movement, while also allowing the traversal of it like it wasn't moving. And once again, I need to sync the jumps that way too even mid air. And make sure character never falls off with violent acceleration and rotation of the vehicle - so, basically make it think the vehicle is not moving. Or at least that's my take on how it should be easiest.
 
Last edited:
For vehicle movement take a look at the drive ability and the IDriveSource. The docs give a bit more info but we have an integration with the various vehicle controllers that you can compare with.
 
I also have this issue. I have a vehicle controller for boats/rafts that uses the physics and rigidbody engine (non kinematic) and I can't find any way to make the character controller stick on top of it once it lands there. Implementing a 'driving' controller seems really backwards.
 
For a boat you don't need to implement IDriveSource. In that situation the Move With Object ability is what you want to use.
 
It seemed the other way around, locomotion was using LateUpdate, and changing it to use Update worked - thanks for that. What implications are there for changing locomotion to use Update that I should watch out for?
 
Top