PlaceAtMe - ObjectReference
Member of: ObjectReference Script
Makes X new references of the passed in form, optionally forcing them to persist, and places them at our reference's location, returning the last one it created.
ObjectReference Function PlaceAtMe(Form akFormToPlace, int aiCount = 1, bool abForcePersist = false, bool abInitiallyDisabled = false) native
- akFormToPlace: The base form to create references of.
- Note: the akFormToPlace can be things such as MiscItem, Actor, ActorBase, etcetera, but it cannot be an ObjectReference
- aiCount: How many references to make at once.
- Default: 1
- Caution: Only the last reference created is returned.
- abForcePersist: True to force the created reference to be persistent.
- Default: False
- abInitiallyDisabled: True to force the reference to be initially disabled
- Default: False
- Caution: This is only applied to the last reference created.
The last ObjectReference that was created. Or None if no references could be created for some reason.
; Place a new box at the target marker ObjectReference newBox = TargetMarker.PlaceAtMe(BoxBase)
; Place a two new boxes at the target marker ObjectReference oneOfTheBoxes = TargetMarker.PlaceAtMe(BoxBase, 2)
; Place a horker at player. Use 0x<FormID>. ObjectReference Horker = Game.GetPlayer().PlaceAtMe(Game.GetForm(0x00023ab1))
; Place a Rock at player. Game.GetPlayer().PlaceAtMe(RockProperty)
- If you want to place a leveled actor, you probably want PlaceActorAtMe - ObjectReference(use with caution).
A common mistake with PlaceAtMe is passing an object of type ObjectReference as its akFormToPlace parameter. Attempting to do so will result in this compilation error:
type mismatch on parameter 1 (did you forget a cast?)
ObjectReference Property MyObjectReference Auto Form MyBaseObject Event OnInit() MyBaseObject = MyObjectReference.GetBaseObject() EndEvent ; ... PlaceAtMe(MyBaseObject) ; ...
- Objects no longer used should be disabled (through DisableNoWait or a similar function) and marked for deletion (through Delete) to prevent them from bloating the user's savegame.
- As with MoveTo and SetPosition, objects created with this method will sometimes appear in odd angles, and it doesn't take in account for uneven terrain. This does not apply the actors. To correct their rotation, use SetAngle, with a 0 X coordinate, and the Y and Z coordinates being whatever you wish it to be.
- Even if you set the object to be initially disabled, its OnLoad event will still fire, and then fire again when you decide to enable it.
- Some forms, like MapMarker, cannot be created at run-time. Attempts to create them will fail silently and return None.