Omegacron Posted March 13, 2018 Share Posted March 13, 2018 I have a static object that I want to rotate horizontally, like a disco ball. This was fairly simple in Oblivion, but apparently it's harder to do with Skyrim scripts. So far all of my searches keep coming up with stuff about rotating the object in the Creation Kit, but that's not what I want. I want the object to actually rotate in place as you're looking at it in the game. For an example, I've been looking at the Eye of Magnus. It rotates exactly like I want (albeit a little fast), but I can't figure out how it's done. I suppose it could be an animation baked into the NIF, but surely you can just rotate an object along an axis using papyrus... Link to comment Share on other sites More sharing options...
varkonasnorse Posted March 13, 2018 Share Posted March 13, 2018 I could be wrong, but I'm pretty sure I read somewhere that anything that moves in Skyrim needs an animation file. If it's just going to sit on a pedestal and rotate or float in one spot and rotate, then you have to also add time sequence settings so it continues to rotate after you avert your focus. You may ignore me, however. According to my wife, I'm only right some of the time. :dry: Link to comment Share on other sites More sharing options...
Omegacron Posted March 14, 2018 Author Share Posted March 14, 2018 You may ignore me, however. According to my wife, I'm only right some of the time. :dry: Hey, at least you get to be right some of the time. After 20 years, I don't even get THAT. :laugh: Link to comment Share on other sites More sharing options...
cdcooley Posted March 14, 2018 Share Posted March 14, 2018 If the rotation isn't built into the nif animation, then you need to attach a script to manage the rotation. Here's one I created a few years ago that should do the trick. Scriptname ContinualRotation Extends ObjectReference Float Property RotationSpeed = 20.0 Auto Event OnInit() OnTranslationAlmostComplete() EndEvent Event OnCellLoad() OnTranslationAlmostComplete() EndEvent Event OnUpdate() OnTranslationAlmostComplete() EndEvent Event OnTranslationAlmostComplete() if Is3DLoaded() Float AngleZ = GetAngleZ() + 120 if AngleZ >= 360 AngleZ = AngleZ - 360 endif TranslateTo(GetPositionX(), GetPositionY(), GetPositionZ(), GetAngleX(), GetAngleY(), AngleZ, 0.0, RotationSpeed) else RegisterForSingleUpdate(0.1) endif EndEvent If it's rotating the wrong direction simply changing the line that adds 120 to subtract 120 instead should let it spin the other direction. But always use 120 and change the speed property if you need it to go faster or slower. Link to comment Share on other sites More sharing options...
Elias555 Posted March 14, 2018 Share Posted March 14, 2018 If the rotation isn't built into the nif animation, then you need to attach a script to manage the rotation. Here's one I created a few years ago that should do the trick. Scriptname ContinualRotation Extends ObjectReference Float Property RotationSpeed = 20.0 Auto Event OnInit() OnTranslationAlmostComplete() EndEvent Event OnCellLoad() OnTranslationAlmostComplete() EndEvent Event OnUpdate() OnTranslationAlmostComplete() EndEvent Event OnTranslationAlmostComplete() if Is3DLoaded() Float AngleZ = GetAngleZ() + 120 if AngleZ >= 360 AngleZ = AngleZ - 360 endif TranslateTo(GetPositionX(), GetPositionY(), GetPositionZ(), GetAngleX(), GetAngleY(), AngleZ, 0.0, RotationSpeed) else RegisterForSingleUpdate(0.1) endif EndEvent If it's rotating the wrong direction simply changing the line that adds 120 to subtract 120 instead should let it spin the other direction. But always use 120 and change the speed property if you need it to go faster or slower.Nice script! Under TranslateTo, would adding an object/actors angle(eg. Bob.GetAngleZ) make the object rotate around the object/actor instead? Link to comment Share on other sites More sharing options...
cdcooley Posted March 15, 2018 Share Posted March 15, 2018 No, having an item orbit around something is very different than spinning in place. When some people looked into that a while back they decided it would be better to create a custom animation pairing than try to do the needed computations in a script. Link to comment Share on other sites More sharing options...
Elias555 Posted March 15, 2018 Share Posted March 15, 2018 If the centre of the nif is moved 100 units to the side and make that the anchor point, would the object rotating on itself now rotate from the centre anchor point? I think that will give the same effect and still make use of your script. By the way, is the script resource heavy? Link to comment Share on other sites More sharing options...
cdcooley Posted March 16, 2018 Share Posted March 16, 2018 Yes, just altering the center point on the nif might work but I've never tried it. The script isn't particularly resource heavy, but the load mainly depends on how fast the object spins and how many items in a particular location might have the script attached. If you're going for a slow rotation then it will have a minimal impact. One factor keeping the load to a minimum is that the script only references that one object so it won't need to get locks on or call remote functions against other objects. You can make it less intensive if you change the update interval that currently runs the script every 0.1 seconds when the object is in a loaded cell, but that also means than the object won't start rotating until that amount of time has passed in some cases (like after a reload of the game while already in that cell). There are certainly original game scripts attached to items that have a higher load than this one. Link to comment Share on other sites More sharing options...
Videogamering1686 Posted April 20, 2020 Share Posted April 20, 2020 Hey I know this is old and I was going to use it for a different game but is there anyway you can help me adapt this so that it trigger when you hit a switch? Link to comment Share on other sites More sharing options...
Recommended Posts