Workshop Teleport with collision

I’m making a workshop gamemode and when I teleport I go through walls and objects which I want collision on. Any tips/help?

rule("Rule 1")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is Button Held(Event Player, Button(Interact)) == True;
	}

	actions
	{
		Teleport(Event Player, Ray Cast Hit Position(Eye Position(Event Player), (Eye Position(Event Player) + Facing Direction Of(Event Player) * 10), Null, Event Player, True));
	}
}

Use a raycast to find out whether your target is within bounds or not.
In case you also want your teleport to stop on players you can also replace the “Null” at the end to the desired players you want to get ‘stuck’ on.

1 Like

Hi, thank you for responding so when I add the second eye position it shows “Event player, All players, Team, All, Event player, True,” i’m not sure why it shows that.

I’d assume you’re missing the Add and Multiply then

Instead of the End Position being just the Eye Position it needs to be

Add
	Eye Position
		Event Player
	Multiply
		Facing Direction Of
			Event Player
		Number
			10

Also as a side note, unless you’re on Console you can staight up just copy the snippet from above and paste it into your workshop game.
Since it uses no variables it also shouldn’t bork up anything that you’ve already changed yourself.

1 Like

You can also subtract (Facing Direction Of(Event Player) * 0.5) from the end position if you want to keep yourself away from the wall a little.

2 Likes