How can I move a door based on character distance?

Hi! I want to make a door that opens when the character approaches it.
When the character goes through the trigger then it will start to calculate the distance between the cha and the door and the door will open depending on the character location.
I hope I explained myself well :))

What might the blueprints look like?

1 Like

Hello!

The graph is a little confusing to me.

Is it showing multiple instances of a single door? Or are there multiple triggers and doors?

Am I correct in understanding you to mean that any time a character collides with a particular trigger, that trigger will activate a corresponding door?

If so, one way you can do this is:

In fact, you could have a situation where ALL the doors pull the distance value from this chart (you would save it as a variable), and use it accordingly, without having multiple triggers.

But I don’t know what your needs are.

1 Like

First of all, I am not the one to judge but this is an unnecessarily long way of doing this.

  • You do not need to get class → get actor of class and so on, you can simply cast the Other Actor to the player character:

  • Or you can make use of Tags and add a simple “Player” tag to the Character:
    image

Now to answer OP’s question, if I got it right, he/she wants a door that will move left/right based on the distance between the player and the door.

To accomplish this, you might do something like this:

Please note that this still will require adjusting to get the desired effect you’d like.

For example, you can use the distance between player & door to calculate the speed of the movement of the door using Lerp:


But as I said, this will still require some adjusting and testing to get the desired effect. However I hope it serves as a valuable starting point!

Good luck.

3 Likes

I appreciate the revisal, but I chose not to cast on purpose.

Good on you for the very clear graphs.

2 Likes

Thanks for the reply! Almost what i want.
I want the door to open in real time with the distance between the character and door. For example on my sketch I have 0 to 3 meters, if I go forward the door will open where I will be between 0 and 3 meters, if I go back the door will close just as it opened. If I stop, the door will stop too.

I made this animation because I’m bad at explaining :))

1 Like