Convert vector from world to local?

So, here’s the scenario I have. I have physics enabled static mesh, and I want to be able to apply a force to it, via blueprint, so that force is applied at a right angle to whatever object it’s touching. So, if the object is laying on a flat plane, the force will be applied upwards. If the object is against a wall, it will be applied sideways opposite the wall. Currently, I’m getting the world location of both the objects, then using “Get Direction Vector” to get a vector between them, and then applying it via “Add Impluse”. However, “add impluse” appears to apply a vector in local coordinates, while the vector I get from the other function is in world coordinates. How can I convert between the two?

Use the “Inverse Transform Direction” node to convert a directional vector from world to local space. However, Add Impulse is not in local space, it’s in world space, so there must be something else going on. Did you try drawing debug lines to see where your vectors are going? Also, feeding the actor world locations into Get Direction Vector won’t give you what you want, it’ll just get you the vector between the origins of each actor. So if your physics-simulating mesh bumps into one end of a long wall, you’ll be getting the vector from the center of the physics mesh, to the center point of the whole wall(assuming the meshes aren’t offset from origin in themselves or in their blueprint). What you can do (and I tested this in my own project) is use Event Hit, which outputs the “Hit Normal”, which is the unit direction vector perpendicular to the object contacted. It uses the collision mesh of course, so it won’t be perfect for complex objects.

That definitely helps me out, thanks! Related to that, do you know any good way to get a boolean of “Is this object touching another hit-enabled object?”? Currently I’m trying adding a trigger volume around the object and then setting a boolean variable value based on the begin/end overlap events, but that’s having dubious results.

Cool, you’re welcome. For your other question, no, not really. Hit events should fire continuously if objects are touching, but unless there’s a force constantly pushing things together (like gravity), they probably won’t technically be touching. A trigger volume might work, but as you’ve probably noticed it gets tricky if multiple objects are overlapping, or if objects can enter the volume and then get destroyed. You can do “Get Overlapping Actors” to check if there’s anything in the volume, if that helps.

Since these are blueprint issues, you might get more answers if you post in the Blueprint forum section. Content Creation is sort of a hodge-podge, and gets less focused attention I think.

Another thing is that objects will go to sleep relatively fast and then all HitEvents between them go silent.

What do you mean by "HitEnabled’? If object specifically respond to OnComponentHit events?

Hmmm, that actually might not be a problem if I can figure out how to make a variable that “expires” a fraction of a second after the hit events stop. That would probably give me the same effect as using the trigger, but without having issues with multiple objects (which is what I’m having now.)

Mid-post-edit: Hah, I actually figured this out. Here’s a little snip of the blueprint for anyone else that wants to know how to solve this problem, using an event dispatcher and a little timer for when the hit “expires”.


Right, if an object has the “Simulation Generates Hit Events” box checked.