Apply Force In Direction Of Line Trace?
Hello, so I have a line trace that aligns my character to the surface and once it reaches a certain point I disable gravity and enable flying so I can go past 90 degrees.
Once I'm in this flying no gravity state though Its very easy for my character to float away from the surface.
My question is how can I apply a directional force (possibly from the line trace?) downward from my character to make them stick to the surface its aligned on?
asked Oct 15 '18 at 05:10 PM in Blueprint Scripting
This is really simple to do because the line trace gives you all the information you need. The hit result will contain something called the impact normal. This is the direction the hit surface is facing.
All you need to do is take the impact normal vector and multiply it by a negative number (opposite of the surface direction) that you feed into an add impulse node. You can do this off of tick or a timer if you need it to be consistently added.
Make sure to check velocity change on the add impulse node to factor in the mass of the target.
Follow this question
Once you sign in you will be able to subscribe for any updates here