Editing
PlaceAtMe - ObjectReference
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
[[Category:Scripting]] [[Category:Papyrus]] '''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. == Syntax == <syntaxhighlight lang="papyrus"> ObjectReference Function PlaceAtMe(Form akFormToPlace, int aiCount = 1, bool abForcePersist = false, bool abInitiallyDisabled = false) native </syntaxhighlight> == Parameters == *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. == Return Value == The last [[ObjectReference Script|ObjectReference]] that was created. Or None if no references could be created for some reason. == Examples == <syntaxhighlight lang="papyrus"> ; Place a new box at the target marker ObjectReference newBox = TargetMarker.PlaceAtMe(BoxBase) </syntaxhighlight> <br> <syntaxhighlight lang="papyrus"> ; Place two new boxes at the target marker ObjectReference oneOfTheBoxes = TargetMarker.PlaceAtMe(BoxBase, 2) </syntaxhighlight> <br> <syntaxhighlight lang="papyrus"> ; Place a horker at player. Use 0x<FormID>. ObjectReference Horker = Game.GetPlayer().PlaceAtMe(Game.GetForm(0x00023ab1)) </syntaxhighlight> <br> <syntaxhighlight lang="papyrus"> ; Place a Rock at player. Game.GetPlayer().PlaceAtMe(RockProperty) </syntaxhighlight> == Notes == <ul> <li> If you want to place a leveled actor, you probably want [[PlaceActorAtMe - ObjectReference]](use with caution). </li> <li> 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: <pre>type mismatch on parameter 1 (did you forget a cast?)</pre> This is the same error as you would see if you were to use an [[Actor Script|Actor]] as the first parameter of [[PlaceActorAtMe - ObjectReference|PlaceActorAtMe]], which should be of type [[ActorBase Script|ActorBase]]. The first parameter of PlaceAtMe should be of type [[Form Script|Form]]. If you need to get a Form from an ObjectReference, use the [[GetBaseObject - ObjectReference|GetBaseObject]] function. <syntaxhighlight lang="papyrus"> ObjectReference Property MyObjectReference Auto Form MyBaseObject Event OnInit() MyBaseObject = MyObjectReference.GetBaseObject() EndEvent ; ... PlaceAtMe(MyBaseObject) ; ... </syntaxhighlight> </li> <li>Objects no longer used should be disabled (through [[DisableNoWait - ObjectReference|DisableNoWait]] or a similar function) and marked for deletion (through [[Delete - ObjectReference|Delete]]) to prevent them from bloating the user's savegame. </li> <li> Objects created through runtime scripting are not hooked up to physics events like [[OnTriggerEnter - ObjectReference|OnTriggerEnter]] until the cell reloads if the object's base form does not already exist in the cell on cell load. [https://forums.nexusmods.com/topic/13458233-physics-events-not-enabled-for-spawned-objects-until-cell-reload/] This can be worked around by calling [[Disable]] and then [[Enable - 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. </li> </ul> * As with [[MoveTo - ObjectReference|MoveTo]] and [[SetPosition - 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 [[SetAngle - 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 - ObjectReference|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. == See Also == *[[ObjectReference Script]] *[[PlaceActorAtMe - ObjectReference]]
Summary:
Please note that all contributions to the CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
CreationKit:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Landing page
Tutorials
Game Systems
Editor Reference
Scripting Reference
Recent changes
Help
Tools
What links here
Related changes
Special pages
Page information
Page values