Jump to content

How does Transform:SetPosition work?

Recommended Posts

How does Transform:SetPosition work? (I mean what are the 3 numbers represent)

I tried Transform:SetPosition(0, 2, 0) but the prefab moves closer to Player
I tried Transform:SetPosition(0, -2, 0) but the prefab spawns on top of Player (kind of)
I tried Transform:SetPosition(0, 0, 2) but the prefab is slightly off ... somewhere



Edit: I'm making a mod where a prefab should be on top of the Player at all time. However this prevents Player from planting (such as pinecone). Player would say "I can't do that". I changed it to SetPosition(0,0,3) and it works but it's "off" and not on top of the Player. See image.

How do I fix this? Make it "invisible" or hover so not taking up ground space, allowing Player to plant pinecone, etc.



Link to comment
Share on other sites


Parent the entity to the player entity for it to follow, and add the "NOBLOCK" tag to make it not obstruct building.

When you set position to a child entity it's relative to the parent's position and rotation.  I believe the X coordinate controls the child's position relative to the forward direction of the parent.  So an offset of (X, 0, 0) would make it appear in front of the player X units.  Z I believe is for left-right relative to the player's facing direction.  Y is height.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

  • Create New...