Teleport to another location
From libopenmetaverse - libomv - Developer Wiki
Contents |
Prerequisites
The following prerequisites are required in order for you to create your first bot by following this tutorial.
Real World
- This tutorial assumes that you were able to successfully build libOpenMetaverse! If you have not compiled libomv, please follow the instructions on the Getting Started wikipage.
- Also, if you have no experience with the C# (c-sharp) programming language, I highly recommend that you stop now and please follow the list of links to csharp tutorials located here.
- A libomv bot that is able to login successfully. If you don't know how to create a libsl bot, please go to the "How to create a basic libSL bot" wikipage
The Code
Note: We are assuming that our main "GridClient" instance variable is named "Client." If you have a different name for this variable, please substitute the name accordingly
//With only a name of a sim and a location Client.Self.Teleport("Ahern", new Vector3(128.0f, 128.0f, 50.0f)); //With the key of a landmark (new!) Client.Self.Teleport(new UUID("The-key-of-a-landmark")); //To your Home Location Client.Self.Teleport(UUID.Zero);
You can also fire an event when a Teleport succeeds or fails:
client.Self.OnTeleport += new AgentManager.TeleportCallback(Self_OnTeleport); //Definition of Self_OnTeleport: static void Self_OnTeleport(string message, AgentManager.TeleportStatus status, AgentManager.TeleportFlags flags) { //message contains any messages regarding the teleport //status is an enum of the current teleport status //flags is various flags regarding the teleport }
Notes
- There are overrides for the Teleport Method that allows you to replace the simulator name (the string in the first example) with the region's numerical handle (an unsigned long)
- You can also add a "LookAt" vector that points the avatar at a specific vector location when the avatar teleports.. Just add it as a third parameter to the first example
- Landmarks have built-in LookAt vectors