Jump to content

Spawn and despawn object spell


Recommended Posts

I don’t quite understand how to make a spell to spawn a static object.
I looked at a couple of other mods for reference, but they use an NPC call so that the object has HP and enemies can bypass it correctly. Or these mods had a complex spawn system with a marker, which in my case is not necessary.
Is there some simple way to just spawn an object in front of the player and unspawn it after a couple of seconds?

Link to comment
Share on other sites

If by spawn you mean to create a new reference instance, yeah.  Here's an example from my WIP mod:

Light property		qvDhOF_RedCandleLight		Auto
Static property		qvDhOF_RedLantern		Auto

ObjectReference 	lantern = None
ObjectReference 	glow	= None

function setInUse( bool inUse)
	if inUse
		lantern = placeAtMe( qvDhOF_RedLantern)
		lantern.moveTo( Self, 0.0, 0.0, 192.0)
		glow = lantern.placeAtMe( qvDhOF_RedCandleLight)
	else
		lantern.disable()
		lantern.delete()
		lantern = None
		glow.disable()
		glow.delete()
		glow = None
	endif
endfunction

 

Link to comment
Share on other sites

My example places the new object above whatever is "Self" in this context (in my case, it's an xmarker, but could be any ObjectReference).

To place in "front" of the player, you'll need a bit more trigonometry to replace my "0.0, 0.0, 192.0", likely using GetHeadingAngle.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...