- Home /
Character Controller affecting Slerp?
I have a simple situation where I'm moving my player onto a higher platform using a slerp. I have tested the exact same code on a standard cube and it works great, exactly what I want, but when I used it on my player, he didn't move at all, or at least he tried but didn't make it, the slerp was definitely happening when it should have. After a bit of fiddling, I found that turning off the CharacterController during play causes the play to move about half way trough the slerp, and then stops.
Another strange occurrence is if I change the speed of the slerp to anything higher than 0.2, the slerp basically teleported me instantly to where I am supposed to go, which isn't what I want. I want the player to move somewhat slowly.
So my question is; why? What is it about the CharacterController that is affecting the player and the slerp function? Or does it affect it at all, and I'm just missing something? Thanks for any help.
Other notes: I tried changing the player's gravity to no avail. I'm also working in 3D.
Answer by FRStudios1998 · May 02, 2019 at 05:48 PM
OK, so I found a fix that works consistently.
As far as I can tell (which isn't far tbh), the CharacterController is being called through my own PlayerController script, which has a gravity float. To keep my player on the ground while I move, I must have made sure that the gravity always pulled the player down to the ground. This interfered with the Slerp which was fighting for control while the gravity tried to push my player down and the Slerp pushed the player up.
While the Slerp happens, I lowered the gravity enough that the player can move smoothly to his end position. Then it reset the gravity. The represented a change from the default -100 to about -5.
I know this fix isn't ideal, so I want to leave it open to likely better suggestions. The slerp and gravity are fighting each other for control, which means that one can be pushed aside while the other does its thing. I just don't know how to do that at present.
I'll post again if I think of a less messy fix.