Transitions and Waypoints
Last updated
Last updated
Let's create transition to that tree! First we start from easy one - teleporting.
First - create transition zone, go to ZONES/ folder and drag transition_zone.tscn to the scene.
Then go to HELPERS/ folder and drag transition_target.tscn to the level.
This helper will be our spawn point when we use transition zone. Let's set transition_zone parameters inside inspector in Keys.
Basic transition zone has:
last_point_is_end - used only with waypoints, last point will be the same as target_object
name - must have unique name for scripts
target_object - name of our helper, will teleport player to target position *can't be empty
waypoints - play walking animation between points and then at the last point teleport player to target position *if empty - only teleport to target
Let's rename our target helper to "tree_target"
Set same name to target_object in transition_zone Keys.
Let's test. We teleported to the helper and looked at the same direction that the arrow is looking.
But let's make it difficult - create some waypoints path.
Click Right mouse button on the level root node and select Add Child Node...
Search for the Path3D.
Click create.
Do not move it from zero XYZ position.
When Path3D is selected you'll see that you have new tools at toolbar at right top corner.
First - select point Second - Select control point Third - Add point Fourth - Delete point Fifth - Close curve
Create first point. with Third button on toolbar (green plus sign with green dot). Also don't forget to switch to top view.
And put first point.
Then go to the inspector and open Curve parameter. Select Points group.
Set Y to 1.7, so the next new points will be at the same height.
Now draw click new point and place the last one close to helper target.
Okay, lets name our Path3D with unique name and put same name intro transition_zone Keys.
Lets test! See, now player walk with these points right into target.
Hey, let's delete target helper and will try to make last point of waypoint ours target!
Keep waypoints name, but delete target_object and turn on last_point_is_end.
Now, let's make transition trigger with level change function! You can do it in a few ways - manual or using prefab. Let's talk about a manual option.
Select transition zone on the current level and change its "id" from "transition" to "transition_to_level" and add a new String key "level" with String value of target level ID. For example - let's set "intro" level from res://assets/levels/
As you can see, after we reach last point of waypoint - we load new level.
I recommend to block rooms between for prevent player use triggers through walls.