Jump to content

Recommended Posts

Hi all,

I was hoping you could help me wrap my head around how animated textures tied to powered workshop items like light bulbs work.

I've got a furniture object that can be powered to produce light. I place the actual light objects via script, they work-great-look-great.

But like any lightbulb in game, the illusion of the mesh being lit up has to be handled via an animated texture. I've never done this before, but getting a rudimentary rig was simple enough. I have a controller quickly animating the emissive multiple from off (0) to on (5). I know I'll need a reverse animation for when power is lost, but I just want to get one working first.

 

I bring the mesh into the CK and preview it, the animation plays fine. But I know that is only half the battle, as there is currently nothing telling the object in game when to play the animation.

Here is where I'm stumped. I already have a script shelled out from placing the light objects (all the OnPowerOn/Off, OnWorkShopObjectPlaced/Moved/Destroyed, etc), but I have no idea how to tell the animation to play, let alone how to control which one plays once I have both the On and Off animations set up. I'm not even sure if I'll need those fancy ControllerManagers or ControllerSequences, as the tut I followed for the float controller didn't go into having multiple states.

Â

Any guidance, as always, is appreciated.

Edited by mmdestiny
Link to comment
Share on other sites

Look for PlayAnimation() for havoc-based anims and PlayGamebryoAnimation() for the older (nif-internal) animations.

Â

https://www.creationkit.com/fallout4/index.php?title=PlayAnimation_-_ObjectReference

https://www.creationkit.com/fallout4/index.php?title=PlayGamebryoAnimation_-_ObjectReference

Thank you for the reply. Perhaps I am simply too unfamiliar with how this all works in nifskope, but are controllers that simply edit settings handled the same way as physical behavior animations (like those in the wiki examples)? I'll definitely give it a try after work tonight regardless.
Link to comment
Share on other sites

Update:

I've gone and got both light fixtures rigged up with an On and Off animation via NiControllerManager. Both animations play properly and concurrently in CK preview.

 

I've hooked up PlayGamebryoAnimation using the NiControllerSequence names ("On" and "Off") but I still do not get the animations to play.

I'm thinking that perhaps I'm not referring to the correct thing when I call the function? Do I need to somehow refer to something within the nif, and not the objectreference? I know SelfREF itself is working because all the stuff with the LightREFs work fine.

Or perhaps is the problem derived from the fact that this is a furniture object, and not an activator? Do I perhaps need to place the "bulbs" in a separate nif, make that nif an activator, and add them to the furniture object with PlaceAtNode before they can play?

ObjectReference SelfREF      ; the object
ObjectReference LightREF01    ; a created light reference
ObjectReference LightREF02    ; a created light reference

Event OnInit()
	SelfREF = Self as ObjectReference
EndEvent

Event OnLoad()
	if SelfREF.IsPowered() == True
		LightREF01 = Self.PlaceAtNode(strAttachNode01, LightToPlace, 1, True, False, False, False)
		
		LightREF02 = Self.PlaceAtNode(strAttachNode02, LightToPlace, 1, True, False, False, False)

		SelfREF.PlayGamebryoAnimation("On")
	endif
EndEvent

;;;;;....and many other iterations of this or the off animation + killing the lights for moving, OnPowerOn, OnPowerOff, destroying, unloading, etc...
Edited by mmdestiny
Link to comment
Share on other sites

- Make sure you have set "Bit 0: Animated" in the BSXFlags of your NIF.

- Also, I think, it would be a good idea to set the second parameter of PlayGamebryoAnimation() to TRUE, otherwise it could happen that the animation is only played once.

 

- The furniture object in CK should have (at least) the following keywords:

WorkshopCanBePowered

WorkshopPowerConnectionDUPLICATE000

 

- You have omitted the Properties in your code snippet, isn't it? :-) Otherwise your code wouldn't even compile.

Link to comment
Share on other sites

- Make sure you have set "Bit 0: Animated" in the BSXFlags of your NIF.

- Also, I think, it would be a good idea to set the second parameter of PlayGamebryoAnimation() to TRUE, otherwise it could happen that the animation is only played once.

 

- The furniture object in CK should have (at least) the following keywords:

WorkshopCanBePowered

WorkshopPowerConnectionDUPLICATE000

 

- You have omitted the Properties in your code snippet, isn't it? :-) Otherwise your code wouldn't even compile.

Hahaha there's a huge chunk of stuff omitted, I wanted to keep the post concise so you didn't have to sift through the irrelevant stuff. I had actually updated the code since my post to include the second parameter as true, but that didn't help.

I'll have to double check my bsx, though I'm fairly positive I have it set to animate=true.

I do have WorkshopCanBePowered and can confirm the REST of the code works, because the LightREFs get placed. What is the second keyword though?

Edited by mmdestiny
Link to comment
Share on other sites

- Make sure you have set "Bit 0: Animated" in the BSXFlags of your NIF.

It was a BSX issue. I did have the Animated flag checked, but apparently needed the Havok flag checked, even though it's a Gamebryo animation. Coincidentally, Bit 0 is the Havok flag, not Animated, so you were still right about Bit 0 being the key.

 

Thanks for the help (though now I'm dealing with a completely separate issue :sad: )

Edited by mmdestiny
Link to comment
Share on other sites

  • Recently Browsing   0 members

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