Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Senior Moderator
staff: senior moderator
Original Poster
#1 Old 20th Feb 2020 at 11:34 AM
Default Adding an interaction to the terrain?

hello again
I'm trying to add a "Collect Water" interaction to water, but I don't know how to actually add the interaction to the terrain, because the terrain isn't like a regular object.
In my OnWorldLoadFinished function, I added
Code:
            Terrain sTerrain = new Terrain();
            Simulator.AddObjectWithId(sTerrain, new ObjectGuid(4294967297uL));

And it added the Collect Water interaction, but it also makes all terrain interactions no longer work...so that was not a success.
So how do I add an interaction to the terrain?

Thanks in advance!
Advertisement
Space Pony
#2 Old 20th Feb 2020 at 3:39 PM Last edited by gamefreak130 : 20th Feb 2020 at 4:18 PM.
Quote: Originally posted by zoe22

hello again
I'm trying to add a "Collect Water" interaction to water, but I don't know how to actually add the interaction to the terrain, because the terrain isn't like a regular object.
In my OnWorldLoadFinished function, I added
Code:
            Terrain sTerrain = new Terrain();
            Simulator.AddObjectWithId(sTerrain, new ObjectGuid(4294967297uL));

And it added the Collect Water interaction, but it also makes all terrain interactions no longer work...so that was not a success.
So how do I add an interaction to the terrain?

Thanks in advance!


Terrain IS a game object, though...it inherits from the GameObject class.

Only one terrain object is ever instantiated by the game at a time, and that object is stored as a static member sTerrain so that other modifying methods have easy access to it. What you're doing is creating a new, blank terrain object that overrides the terrain object the game was using, which could potentially have more severe side effects than just losing access to some interactions. Instead, you can just do this:

Code:
if (Terrain.Singleton != null)
{
    //Assuming the interaction class is CollectWater
    //If you aren't using a singleton, just pass in a new CollectWater.Definition()
    Terrain.Singleton.AddInteraction(CollectWater.Singleton);
}

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Senior Moderator
staff: senior moderator
Original Poster
#3 Old 20th Feb 2020 at 5:20 PM
Thank you gamefreak, I knew what I was doing was very wrong
Back to top