It seems so simple and is the basic feature per se. Nontheless I still stuck with it, although I tried all, I repeat all of them.
Here’s a list of my total attemps, from first to last:
- Transform only while Update()
Position rotation updates during Update() works like a charm, but we need some collision detection…
- Character Controller
Basic, simple, fast via CharacterController.Move(Vector3) with some “tiny” issues. First of all the capsule is fix, means it cannot be replaced by any other collider. Secondly the collision detection is a total fiasco. It can register collsions with OnControllerEnter() but neither has the ability to push/draw other objets via physics nor triggers OnCollisionEnter on the affected rigidbody.
My bullets are rigidbodies and carry their (damage/owner) information with them, therefore I want the collision detection be handled by the bullets and not by the affected character. Means a strike for Character Controller.
- Transform + Rigidbody while Update()
I move and rotate the transform with the input and the rigidbody avoids running through the walls. But as soon as I touch a surface the rigidbody recieves a pulse and will float through the room with an additional velocity. By resetting it 0 during each update frame I can negate this effect, nontheless I’m able to penetrate surfaces very deep and sometimes slip right through them because transform movement is NO physical movement and won’t detect surfaces until the rigidbody will push it out somehow during the next physics cycle.
- Rigidbody Velocity while Update()
The more experienced ones will recognize the problem within a second: Never update physical values (velocity) in Update() if you want them to interact with other objects. It results in a very laggy gaming experience… next try.
- Rigidbody Velocity while FixedUpdate()
It works, it runs, it is smooth ------- oh wait! It’s laggy! But why? Oh yeah, the interpolation is turned off, here it comes:
- Rigidbody Velocity + Interpolation while FixedUpdate()
Will it work this time? Hopefully? My hopes were crushed instantly. Still laggly and it took quite a long time to find out why: The camera following the character refreshes its position/rotation during each update cycle and not during each fixed update cycle. Furthermore only the input during the fixed update cycle is registered, so round about every 6th input gets lost. I won’t to touch the camera script (don’t fix what ain’t broken), so we need another solution on the character.
X) I ran out of skills
I know what I want: New position/rotation during each casual update cyle with collider collision detection + collision detection during fixed update for other colliders + custom collider (+ being able to apply forces on it). I need a rigidbody in each case, but one that won’t stuck in walls when being moved during update.
Possible solution may be Rigidbody.MovePosition(Vector3), but I guess this is only updates each fixed update cycle?
Or by creating a custom Move Method with collision detection like the one from character controller?
I’m sure there’re more people who had this issue, I’d be very pleased about your experiences and (mabye even working) solutions.
tl;dr: No way around it - sorry.