Hi, I am looking to recreate a teleporting system from Dishonored.
I want to be able to teleport upto 10 metres, choose teleport location in this radius and not be able to teleport trhough obstacles like walls. Please help!
One of the first resultsfrom Googling “ue4 teleport player”.
As you may guess the first or the second result may not be always relevant to the question. I have seen this thread before and it’s has nothing to do with my question as
I cant choose teleport distance and I go through objects when I teleport with this method
Hey QurbanOlum,
This is fairly easy - here are the high level steps:
- Do a Line Trace by Channel and shoot it forward up to 10 meters (use the same setup as in that thread with your forward vector).
- Then break the Hit Result and check if you hit something. If you did NOT, then teleport by using the method in that thread.
- If you hit something, grab the Hit Location and subtract it from the Actor Location. Then get the Vector Length and multiply this by 0.9.
- Then use this new Float value and multiply it by your Actor Forward Vector and grab this vector and teleport to this location.
Basically, if you hit something with the line trace, you want to get the distance between the Player and the hit location and reduce the distance by some percentage (in this case I got 90% of the distance). Then multiply this distance to your Forward Vector to get the new vector location. Use this location and teleport there.
Hope this helps!
Thanks man, will try it