[DEV SERVER] Loading description...
Caveats
CK Wiki - Notes
-
If you want to place a leveled actor, you probably want ObjectReference.PlaceActorAtMe(...)(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?)This is the same error as you would see if you were to use an Actor as the first parameter of ObjectReference.PlaceActorAtMe(...), which should be of type ActorBase.
The first parameter of PlaceAtMe should be of type Form. If you need to get a Form from an ObjectReference, use the ObjectReference.GetBaseObject() function.
ObjectReference Property MyObjectReference Auto Form MyBaseObject Event OnInit() MyBaseObject = MyObjectReference.GetBaseObject() EndEvent ; ... PlaceAtMe(MyBaseObject) ; ... -
Objects no longer used should be disabled (through ObjectReference.DisableNoWait(...) or a similar function) and marked for deletion (through ObjectReference.Delete()) to prevent them from bloating the user's savegame.
-
Objects created through runtime scripting are not hooked up to physics events like OnTriggerEnter until the cell reloads if the object's base form does not already exist in the cell on cell load. This can be worked around by calling Disable and then ObjectReference.Enable(...) on the object, which will immediately update the engine. Since non-physics events like OnInit function correctly, this can easily be rectified by re-enabling the object in OnInit on the spawned object.
- As with ObjectReference.MoveTo(...) and ObjectReference.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 ObjectReference.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.
Parameters
FormakFormToPlace
CK Wiki Description
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
intaiCount=1
CK Wiki Description
How many references to make at once.
- Caution: Only the last reference created is returned.
boolabForcePersist=false
CK Wiki Description
True to force the created reference to be persistent.
boolabInitiallyDisabled=false
CK Wiki Description
True to force the reference to be initially disabled
- Caution: This is only applied to the last reference created.
Examples
; Place a new box at the target marker
ObjectReference newBox = TargetMarker.PlaceAtMe(BoxBase); Place 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)Auto-Generated Example
Form myForm__akFormToPlace
int myInt__aiCount
bool myBool__abForcePersist
bool myBool__abInitiallyDisabled
ObjectReference returnedValue = myObjectReference__toCallFunctionOn.PlaceAtMe(myForm__akFormToPlace, myInt__aiCount, myBool__abForcePersist, myBool__abInitiallyDisabled)