Prager Independent Learning Unity Transportation

Prager Independent Learning Unity Transportation


While creating my project I quickly realized I needed to learn how to transport the player throughout the scene on trigger. Initially, I thought you would be able to simple do this by creating an FSM on the first person controller and creating I Tween between different objects scattered throughout the scene. I quickly found out that was not the case.

I began researching how to transport a character throughout a Unity scene. I came across multiple blogs and forums that suggested doing the opposite of what I was trying. They suggested that I have I tween set on an object but have the user be a selected user and have that be the FSPController. I did this but every time I would enter the trigger the FSPController would either glitch or continuously ram into the trigger, but still not transport anywhere I wanted it to go. I tried to adjust the speed to 0 with the delay at 0 and time at 1, but this would still make the controller glitch continuously. I tried to set the speed to 1, but any other speed than zero makes the controller move to the specified destination, but it goes through the terrain to move – I wanted this to be an instant teleportation.

I did some more blog searching and found Move Object in the action search of FSMs. This essentially is the same as I Tween. I put the specified object as the FSPController, but was still getting the same results. On each object I just have two states with transitions trigger enter and finish.

I next found this asset called Teleport. This included teleport prefabs, a teleport script, and an example scene. It also has video in the asset store to demonstrate the teleport pads, essentially it showed exactly what I have been trying to do. I thought this could be the answer to my teleportation problem. When putting the prefab into the scene I set the settings to move any player that entered the trigger to be teleported. I changed the settings of the FSPController and camera to player. This is at the top of the inspector once each component is clicked. I set another cube as the destination and the speed to be 0. But, when in game mode it still did not work. I tried keeping the FSPController on main camera settings, but that didn’t work. I went back to the original cube I was trying to set as a trigger to transport with I Tween or Move Object and imported the script from the Teleport Asset into the inspector on the cube. I then went into the FSM to see if there was a transport option or something similar, but the I Tween and Move Object was the closet and even with the script it didn’t work.

This still confuses me why I couldn’t get this asset to work, especially since it came with directions and a video.

I then decided to delete the teleport script and asset from my project. I went back into the 3D Objects that had the Move Object setting in their FSM. I watched parts of the Lynda tutorial on transformation and realized that the reason why my FSPController kept ramming into itself or continuously going back and forth between the two destinations was because the second state needed to end. I had already had the second state with the transition Finished, but that transition had to come after the action was completed and the trigger was exited. I then added a Trigger Exit to the state and had the Finished transition come after. I used Move Object with the object specified as the FSPController, time set to 1, delay set to 0, and speed set to 0. I had loop set to Finished too. Now with the Trigger Exit transition added before the Finished transition, when the player enters the trigger it is transported to the specified destination and stays there. This is because when it gets moved to the object it leaves the trigger thus ending the teleportation process and this then will be ended by the Finished transition.

It ends up being an extremely simply process to program, but getting there took a lot of time! Many of the blogs and forums had to do with coding, but there is always a way to get around coding. I just applied the basic concept of how to move an object and changed the object to be my FSPController.

I learned that everything in Unity has about 5 different ways to get done and you just have to keep trying and checking different buttons or comparing results with others to get the results you want. In the end it’s all relatively easy, just a tough process in the middle, but definitely worth it in the end.

Here is the link to the step by step tip sheet I made to make it easier for other!

http://www.vrstorytelling.org/tip-how-to-trans…r-within-a-scene/

No related post

COMMENTS

LEAVE A REPLY

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.