ZeroCore Posted March 27, 2017 Share Posted March 27, 2017 (edited) Hi. I have a script that's essentially a flight mod for morrowind-style levitation that uses a pair of invisible "stepping stones" as a means of making an invisible floating bridge beneath the player that essentially lets them "walk on air" or at least appear to. I have 2 static objects, a pair of re-textured (or rather un-textured, via the null texture set) circular rugs. The script is supposed to call them, one by one, to the player and set their rotation and angle local to the player's. When the player crouches, the script stops its "update" loop and the rugs should be disabled. Here's the script: Scriptname _YetAnotherFlightAttempt extends activemagiceffect ObjectReference Property FlyingCarpetA Auto ;these two contain the invisible rugs (round rugs with the null texture set put on their meshes; they are static objects) ObjectReference Property FlyingCarpetB Auto ObjectReference Property LoadedCarpet Auto ;the carpet that is currently set to be moved and tilted by the script Actor Property ThePlayer Auto ;the Player int SwitchInt ;This int is for a sort of switch that lets you move the two rugs/platforms independantly of one another when used in conjunction with an update and a conditional statement (an "if" statement) float space ;distance between the player and the loaded rug. Function SetLocalAngle(Float LocalX, Float LocalY, Float LocalZ) float AngleX = LocalX * Math.Cos(LocalZ) + LocalY * Math.Sin(LocalZ) float AngleY = LocalY * Math.Cos(LocalZ) - LocalX * Math.Sin(LocalZ) LoadedCarpet.SetAngle(AngleX, AngleY, LocalZ) EndFunction ;THIS FUNCTION IS VERY IMPORTANT. It sets the rug's heading local to the players. EVENT onEffectStart(Actor akTarget, Actor akCaster) SwitchInt = 1 ;sets the switch to one, so it has something to start at FlyingCarpetA.enable() FlyingCarpetB.enable() ;turns the rugs on LoadedCarpet = FlyingCarpetA ;setting this before everything else as a sort of "fail safe" when it comes to which rug is the current one. RegisterForUpdate(0.1) ;starts the loop EndEvent EVENT onUpdate() space = LoadedCarpet.getDistance(ThePlayer) ;shows the distance between the player and the loaded rug if (!ThePlayer.isSneaking()) ;makes sure you're not sneaking if (space < 80 && space > 70) ;checks distance if (SwitchInt == 1) ;the switch LoadedCarpet = FlyingCarpetA ;a bit redundant, I suppose, but it might help a confused script LoadedCarpet.moveto(ThePlayer) ;SHOULD move it to the player SetLocalAngle(0.0, 0.0, 0.0) ;levels it out in case it's angles are weird LoadedCarpet.SetPosition(ThePlayer.GetPositionX(), ThePlayer.GetPositionY(), ThePlayer.GetPositionZ() - 15) ;sets position to the player SetLocalAngle(ThePlayer.GetAngleX(), 0, ThePlayer.GetAngleZ()) ;sets the angle local to the player SwitchInt = 2 ;DID YOU. JUST FLIP. MY SWITCH? RegisterForUpdate(0.1) ;loop elseIf (SwitchInt == 2) ;see the stuff above. LoadedCarpet = FlyingCarpetB LoadedCarpet.moveto(ThePlayer) SetLocalAngle(0.0, 0.0, 0.0) LoadedCarpet.SetPosition(ThePlayer.GetPositionX(), ThePlayer.GetPositionY(), ThePlayer.GetPositionZ() - 15) SetLocalAngle(ThePlayer.GetAngleX(), 0, ThePlayer.GetAngleZ()) SwitchInt = 1 RegisterForUpdate(0.1) endIf elseIf (ThePlayer.isSneaking()) FlyingCarpetA.disable() FlyingCarpetB.disable() endif endif EndEvent The issue is this: the rugs won't move. At all. Even when the player is in the same cell as them. I even added their old, regular textures back (making them visible again) to see if they were even moving at all. They're not. Also, all the properties are filled out; I've checked, and both the rugs have a unique reference ID, namely FlyingCarpetA and FlyingCarpetB, and I did manually fill the properties, all of the ones that needed filling (the carpets, and the player), in the magic effect's properties window. If anyone can offer some help here, I'd appreciate it. Edited March 27, 2017 by ZeroCore Link to comment Share on other sites More sharing options...
Recommended Posts