I’m trying to tilt an actor based on the current acceleration.
Using the Character Movement component with Get Current Acceleration, i am able to get the pure acceleration of the actor, meaning just the acceleration based on input. If i let go of the controls, my character decelerates, but Get Current Acceleration returns (0, 0, 0). This, sadly, is intended behaviour according to the documentation.
I want to get the true acceleration in a physical sense. meaning a backwards facing (negative) acceleration vector, every time my character slows down.
Do you have any idea on how i can achieve this?
I want my character to tilt backwards, when he decelerates, similar to the behaviour described in this video by David Rosen of Wolfire Games
I might go the route of storing the current velocity every tick and then calculate the “true” acceleration using the current velocity, the velocity stored in the previous tick and Delta Seconds.
However i’m not satisfied with this solution, as im sure that the engine already calculated this internally and i don’t trust my mathematical ability to create a stable system. Reinventing the wheel and all that.
outputs -980.0 while jumping. This setup seems to work for the moment.
UPDATE2: Sadly this solution does not solve having the character tilt towards acceleration. As soon as the character reaches teminal velocity ( Max Walk Speed ) the effective acceleration is 0 and the character stands upright again. Oh well…
The problem here is that your acceleration is coming from the input component. Your deceleration on the other hand is coming from LACK of input. So you’d have to go into the systems that convert lack of input into slowing down, and figure out how to expose that. I don’t see anything in the engine that exposes that for you. I think your velocity calculations are the best way to handle this in blueprint currently.
as i understand it, the Character Movement component handles deceleration as it handles the values for Max Deceleration, Breaking force etc. But the current deceleration does not appear to be exposed.
edit: Whoops not really. It exposes location and I need velocity. I rather store “last tick velocity” locally, because if I use location to calculate acceleration, I have to worry about cases of teleportation and the likes.