Can someone help me and tell me how to make a script that teleports me forward a bit so I can go through walls and out of bounds when I press my interact button.
I am new to workshop and its confusing.
Can someone help me and tell me how to make a script that teleports me forward a bit so I can go through walls and out of bounds when I press my interact button.
I am new to workshop and its confusing.
rule("Teleport")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Is Button Held(Event Player, Interact) == True;
}
actions
{
Teleport(Event Player, Add(Position Of(Event Player), Multiply(Facing Direction Of(Event Player), 10)));
}
}
You can copy+paste this into your Workshop script.
Explanation:
Is Button Held(Event Player, Interact) == True is a condition that works whenever the Event Player (who could be anyone, because an Ongoing - Each Player rule will check every player) is holding the Interact button.
Teleport(Event Player, ...) will teleport the player who is pressing the Interact button to the specified postion. Which is Add(Position Of(Event Player), Multiply(Facing Direction Of(Event Player), 10)).
Let’s break that down,
Position Of(Event Player) gets the position of the Event Player, which is usually located at the bottom of most heroes’ feet.
Facing Direction Of(Event Player) gets the facing direction vector of the Event Player. This vector represents the direction that you’re aiming. It always has a length of 1 meter, because it’s just a direction and not a position.
But let’s say we want to teleport 10 meters in the direction we’re facing, not only 1 meter. That’s why we multiply the Facing Direction Of(Event Player) by 10. In Workshop code, this is:
Multiply(Facing Direction Of(Event Player), 10)
The final step is to add these two vectors together, like this:
Add(Position Of(Event Player), Multiply(Facing Direction Of(Event Player), 10))
This will be the player’s current position PLUS 10 meters in the facing direction of the player.
That’s the position we want, so that we can teleport 10 meters in the direction we’re aiming. So we put it into the Teleport action.
Teleport(Event Player, Add(Position Of(Event Player), Multiply(Facing Direction Of(Event Player), 10)));
what about walking into a sphere and getting teleported to a certain place?
Then teleport them to (Vector that you want to teleport them) if the distance between themselves and the (Sphere Vector) is ≤ (radius).
can you take a screenshot of the acual rule ingame?