Not Understanding Transforms And Parent GameObjects

Discuss modding questions and implementation details.
Post Reply
User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Not Understanding Transforms And Parent GameObjects

Post by Magicono43 »

So I have been completely lost the past few days trying to understand why these objects are not being placed in the scene like I'm expecting. I'm trying to do some testing to implement something for a mod I'm working on by placing a sign-post object somewhere in the player ship when you transition into this scene. The sign-post is being created fine, but the placement of said object is not working intuitively, for me at least.

Here are just some images I took that might give some context.
Capture3.PNG
Capture3.PNG (63.5 KiB) Viewed 907 times
Capture2.PNG
Capture2.PNG (189.63 KiB) Viewed 907 times
This is the closest I have been, that being at least the "Interior" GameObject seems to be attached to the objects I'm creating, but for some reason the transform is nowhere near where I want them to be, and these are essentially the same spots they keep being put in with other methods I used when they were not even attached to the Interior GameObject.

I tried to copy how the Decorator mod was doing it's thing, but was having too many issues and was not making much sense to me so decided to just keep trying my method that keeps having this issue of transform placement being way off.

Thanks for anyone that might be able to help me with this one, right now this transform issue is being quite a barrier to what I want to do with this current mod unfortunately.

l3lessed
Posts: 1399
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Not Understanding Transforms And Parent GameObjects

Post by l3lessed »

I don't know a ton about interior transforms placement. I had similar issues with exterior because of how the transform positions translate in the actual world.

The only thing I can see looking at your code is your grabbing the whole interior block and using that as the parent position for the object. Using the transform from the interior block itself would not give you accurate transform placement positions from my understanding. You need to find the specific position within the interior block itself. As an example, for my minimap door markers in the interior, I had to get the dungeon exit door position from the interior block, and thankfully, there was already a list in place of the doors and a method to find the specific door I wanted for placing the icon for the minimap.

You may have to setup a way to go through the sub-blocks that make up the interior and see if they provide a more accurate transform. This is how exterior placement worked for me. I had to go through the differing rmbblocks that make up the exterior cell's city to get the properties and things I needed for placing my markers.

What are you trying to do with this sign placement?
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: Not Understanding Transforms And Parent GameObjects

Post by Magicono43 »

l3lessed wrote: Mon May 23, 2022 9:03 pm What are you trying to do with this sign placement?
I'm trying to place flats and 3D objects in fixed positions on the ship interiors. While the game normally does stuff like this through reading the block-data and translating that into objects with positional properties, etc. In this case I want to (if possible) place these "new" objects in the scene without having to edit the block data for the interior in question, as I don't think this should be necessary, I should just be able to place objects where I want if I just give them those properties myself, such as vector3 and such, rotation, etc.

But so far the parent objects and their transform just don't appear to be cooperating at all. Like there are 2 3D crate objects in this particular small ship interior scene and they both have x,y,z transform values, that I have to assume have the same parent transform of the interior itself, since they are "nested" under the Interior. I put that transform values manually for the first spawned sign-post object at least, but it's still spawning way outside where the rest of the other non-position based scene objects are like mod objects and such, but with a slightly different spot due to the manually given values. But I just don't get why while the sign-posts appear to be attached to the Interior gameobject and with supposedly the same parent transform, why they are not spawning anywhere near it.

Edit: But yeah, I'll try and see if I can somehow get the sub-blocks or some other values to use the transform of to get a more accurate positional value to use, thanks for the suggestion there.

l3lessed
Posts: 1399
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Not Understanding Transforms And Parent GameObjects

Post by l3lessed »

I think you may be over complicating this.

I just ran a check on creating a object in an interior scene and then moving it to a adjusted position. This was able to create this object arrow in the center of the interior and then move it down to the height/y position of the player.

Code: Select all

GameObject gameobjectPlayerMarkerArrow = GameObjectHelper.CreateDaggerfallMeshGameObject(99900, GameManager.Instance.PlayerEnterExit.Interior.transform, false, null, true);
gameobjectPlayerMarkerArrow.transform.position = new Vector3(GameManager.Instance.PlayerEnterExit.Interior.transform.position.x, 0, GameManager.Instance.PlayerEnterExit.Interior.transform.position.z) + new Vector3 (0,GameManager.Instance.PlayerMotor.transform.position.y,0);
It creates the mesh object using the GameObjectHelper, assigns the interior as the parent, and then updates the position. To show you the two seperate positions I'm using to create the new vector3 for the placed object, I broke them apart and added them together. You can see, I use the interior object to set the x and z (this centers it horizontally in the interior block); I then add the players y position to move it down to the door level/player level on entering.

Also, I believe there is a different between adding a mesh object as a separate object post scene creation, which is what I'm doing, and adding the models/objects to a scene, so when the engine calls the scene is creates it with the scene. I do not know how this second process works, as I haven't done it, but I'm sure they have the object calls to do this.

If you do not want to inject it into the scene building, just create a check for the scene name you want to mod, and if it matches the interior you want, then just place everything via my method, post scene creation.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

l3lessed
Posts: 1399
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Not Understanding Transforms And Parent GameObjects

Post by l3lessed »

I just did some searching through the API and code, and I can find where to access scene information and interior block information, but I do not see a way to inject custom objects into the specific interior scene, so it generates with the scene.

Maybe I'm overlooking something.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: Not Understanding Transforms And Parent GameObjects

Post by Magicono43 »

l3lessed wrote: Tue May 24, 2022 9:47 pm It creates the mesh object using the GameObjectHelper, assigns the interior as the parent, and then updates the position. To show you the two seperate positions I'm using to create the new vector3 for the placed object, I broke them apart and added them together. You can see, I use the interior object to set the x and z (this centers it horizontally in the interior block); I then add the players y position to move it down to the door level/player level on entering.

Also, I believe there is a different between adding a mesh object as a separate object post scene creation, which is what I'm doing, and adding the models/objects to a scene, so when the engine calls the scene is creates it with the scene. I do not know how this second process works, as I haven't done it, but I'm sure they have the object calls to do this.

If you do not want to inject it into the scene building, just create a check for the scene name you want to mod, and if it matches the interior you want, then just place everything via my method, post scene creation.
Yeah, I know that using the player positional reference is generally a pretty good way to place certain objects in a scene. However, in this case I want these placed objects to always be in the same positions in said interior, and while this method may mostly work fine if the player enters from the same entrance point, what if they say set an anchor and teleport back to that position? Then at least if I'm understanding all the added objects will then be placed in completely different spots centered around wherever the player set their anchor, instead of the original assumed reference point of the "main entrance" door.

I tried a few more things and still was being met with no success in getting the objects near the final position that the interior/player is placed when the scene is created for the inside of the small ship. Sort of took a break to work on some other mod ideas instead of continuing to bash my head against the wall with this issue. I'm sure it's something really dumb, but I can't really find any good examples where new objects are created in an interior scene and the player is not used as the "center point" for placing said objects around.

Oh yeah, I also could not seem to find any particularly useful "sub-block" info for the interior of the small ship, at least not values that are translated to something that makes sense to me in the end scene product of where they are being placed and combined and such.

l3lessed
Posts: 1399
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Not Understanding Transforms And Parent GameObjects

Post by l3lessed »

No, you're not understanding this.

I'm not using the players position for anything, other than setting the height. That was just a random thing I choose. You can not use the player. You could just add or subtract whatever x,y,z values you needed from the interior parent transform to place it in whatever spot you want. Since it is using the interior block as the base transform, it should always create it in the same spot, not matter where the player is when entering the interior.

Again, set the parent transform as the interior transform:

Code: Select all

 GameManager.Instance.PlayerEnterExit.Interior.transform
It will center the object dead in the middle of the interior block. At that point, just add or minus whatever vector3 numbers you need to to move it from that center spawn point. In the below example, it moves the object from the center of the interior block by 10.5 units on the x transform and minus 10 units on the Y transform. Since this is using the interior block as the parent/base transform, and then adding or subtracting from it, it should always appear in the same spot in that interior block with this method.

Code: Select all

gameobjectPlayerMarkerArrow.transform.position = GameManager.Instance.PlayerEnterExit.Interior.transform.position + new Vector3 (10.5,-10,0);
I just ran this code myself in an interior building, and I was able to place the object exactly where I wanted it by just offsetting the interior transform vector3 by adding or subtracting a new vector3 from it.

Also, upon researching, there are no sub-blocks for interiors. They are only used for exterior cities and dungeons.
Last edited by l3lessed on Tue May 24, 2022 11:18 pm, edited 1 time in total.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: Not Understanding Transforms And Parent GameObjects

Post by Magicono43 »

Alright, I feel like I have tried something like this already, but I'll give it another shot how you described when I feel like working on this particular mod idea again, and hopefully it works out next try. Thanks for the added info, will update when I get to it.

l3lessed
Posts: 1399
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Not Understanding Transforms And Parent GameObjects

Post by l3lessed »

I'll mess with it some more when I have time, but I loaded into an interior real quick, ran the code, and the arrow object popped into the interior, right where I asked it to.

Could any code where not seeing also be affecting it's position?
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Post Reply