• News

• Industries

• Learning & Support

• Community

• Marketplace

Get distance to actor - Pivot

Hi. I’m using ‘Get distance to’ actor and on click for example to open a door ( I’m using this instead of line trace because the game will be for mobiles ) and I want to touch the object to perform an action. The problem is with the doors, where my pivot is in the left bottom corner so I can animate open/close the door. So if my pivot is there Get distance to will calculate the distante from the left corner and if I’m in the right place of the door the action is not triggered anymore. How can I use ‘Get distance to’ to calculate the distance without considering the pivot. First I’ve used Line trace by channel for testing and there it was considered by the collision box.
Here is the bp I’m using. It’s simple as that.
Thank you!

Hello! How about adding a scenecomponent in the middle of the door, only for world location usage?
then get distance to the scencomponent.

A collision box would be the simplest way to see if your player overlaps, another option is that you make your own “getdistanceto” macro with (vector - vector) and get the length of it. That way you can re-calculate the vectors as you need.

@Muntrax thanks for the tip. I’ll try it.
@Lambdarevolution what in the same place I’ll have 3 objects to interact with? For example if I want to open a drawer and to pick up a key.
Vector - vector will not calculate the distance considering the pivot? It’s not the same thing?
Thank you!

Vector - Vector means just what it says, you would need to get or calculate thoose vectors yourself. Your GetDistanceTo means Center Actor - Center Actor and gets a length from that. Since you need it to be from another point you would need to find the vector of that point. Now if you dont like doing it in math adding a socket to your mesh where you want to measure from would give you a vector to use.

Cant see how the number of objects would make this harder. If the player needs to do them both at the same time you would simply measure the distance per object.

GetComponentBounds will have an origin vector which is the center of the StaticMesh. You can just use that.

@GarnerP57 thank you! Solved it! Sometimes when I’m in the left or the right part of the object the distance is different even if I’m at the same distance, but it’s too little to make a feel.
Thank you again!