DarthRaff Posted January 2, 2013 Share Posted January 2, 2013 Hello, I have that code that works perfect: require("scripts/class") require("Scripts/constants/engine_const") local class=CreateClass(...) function class:InitDialog(grid) self.super:InitDialog(grid) group=grid:AddGroup("Rotation") group:AddProperty("rotationspeed",PROPERTY_VEC3) --group:AddProperty("rotationspeed",PROPERTY_FLOAT) end function class:CreateObject(model) local object = self.super:CreateObject(model) object.model:SetKey("rotationspeed","0.0,1.0,0.0") --object.model:SetKey("rotationspeed","1.0") function object:SetKey(key,value) if key=="rotationspeed" then self.rotationspeed = StringToVec3(value) --self.rotationspeed=(value) else return self.super:SetKey(key,value) end return 1 end function object:Update() if KeyHit(KEY_E) == 1 then self.rotationspeed.y=self.rotationspeed.y*-1 --self.rotationspeed=self.rotationspeed*-1 end model:Turn(self.rotationspeed,0) end end If i comment the rotationspeed Vec3 property and uncomment the rotationspeed float property, and the other changes, it doesn't work. I try to look in the scripts and models folders to do my self but can't find the solution. I want to use just a float version of the rotationspeed property. can someone, please, help me ? thank you Quote Link to comment Share on other sites More sharing options...
macklebee Posted January 2, 2013 Share Posted January 2, 2013 i havent tried your code to see what else would be wrong, but the TurnEntity command is looking for a Vec3... so just change that line: model:Turn(self.rotationspeed,0) to: model:Turn(Vec3(0,self.rotationspeed,0),0) just playing around with the script, but this allows you to set the speed via the property dialog and pressing 'E' will rotate it opposite of current speed. require("scripts/class") require("Scripts/constants/engine_const") local class=CreateClass(...) function class:InitDialog(grid) self.super:InitDialog(grid) group=grid:AddGroup("Rotation") group:AddProperty("rotationspeed",PROPERTY_FLOAT,"2|-10,10,0") group:Expand() end function class:CreateObject(model) local object = self.super:CreateObject(model) object.model:SetKey("rotationspeed", 1.0) function object:UnlockKeys() self.rotationspeed = self.model:GetKey("rotationspeed") end function object:Update() if KeyHit(KEY_E)==1 then self.rotationspeed = self.rotationspeed*-1 self.model:SetKey("rotationspeed", self.rotationspeed) end model:Turn(Vec3(0,self.rotationspeed,0),0) end end Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
DarthRaff Posted January 2, 2013 Author Share Posted January 2, 2013 Thank you very much, that's what i looking for by now. I'm try to translate a door system in lua. I have it working on c++ but i want to see the behaviour of the system in the editor. Thank you again Quote Link to comment Share on other sites More sharing options...
macklebee Posted January 2, 2013 Share Posted January 2, 2013 for a door i would probably use RotateEntity so you have control over the open/close angle easily... then have the controller send a message to the door if its picked to either open/close the door... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Canardia Posted January 2, 2013 Share Posted January 2, 2013 I would use a physics door, because then you have automatically all the logic to block access to the room. Instead of TurnEntity, just use SetBodyOmega with CalcBodyOmega. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
DarthRaff Posted January 2, 2013 Author Share Posted January 2, 2013 Ok, thank you everybody, i will try Quote Link to comment Share on other sites More sharing options...
Guest Red Ocktober Posted January 3, 2013 Share Posted January 3, 2013 i would use neither of the above (don't beat me up Mack, Mika ), and settle for a simple animated door, with a simple physics blocker, and a trigger region... --Mike Quote Link to comment Share on other sites More sharing options...
Pixel Perfect Posted January 3, 2013 Share Posted January 3, 2013 I tried using an animated door but ran into culling problems where the door would disappear whilst seemingly in view. It turned out to be a bounding box issue. If you use animated doors you'll need to take this into account. Here is the advice I was given by Josh: The pivot itself doesn't matter, it's the bounding box. I recommend against making mechanical objects (like a door) a skinned mesh because it is more expensive to render, and there is no reason to use skinning. But in any case, if an animated mesh has animations that cause vertices to move far away, so that the object's bounding box is totally redefined, you should add a couple of vertices in the model to make sure the original bounding box encompasses the object's vertices when animated. I settled for a simple rotation, as suggested by Mack above, in the end. Quote Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++ Link to comment Share on other sites More sharing options...
DarthRaff Posted January 3, 2013 Author Share Posted January 3, 2013 Yes, i'm agree with Mack and Pixel, i tried it before, out of the editor, and works very well. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.