Jump to content

Another question


DarthRaff
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

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

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Guest Red Ocktober

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

Link to comment
Share on other sites

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.

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...