Jump to content

AddTorque X axis always global


Recommended Posts

After spending hours trying to find why i was getting bezare results i have found that it appears the X axis of the AddTorque function is always global despite setting it to local, other axis seem fine. Unless im doing it wrong.

 

Attatch a script to some CSG and add this then run and spin, you will see:

 

function Script:Start()
self.entity:SetGravityMode(false)
end

function Script:UpdatePhysics()
local window=Window:GetCurrent()

local xaxis = ((window:KeyDown(Key.Up) and 1 or 0) - (window:KeyDown(Key.Down) and 1 or 0))
local zaxis = ((window:KeyDown(Key.Left) and 1 or 0) - (window:KeyDown(Key.Right) and 1 or 0))
local yaxis = ((window:KeyDown(Key.Z) and 1 or 0) - (window:KeyDown(Key.X) and 1 or 0))

torque = Vec3(xaxis*50,yaxis*50,zaxis*50)
self.entity:AddTorque(torque,false)
end

 

EDIT: Im not sure its JUST the X axis, if its not that the X axis is always global then something very strange is happening with its local coordinates

 

Change the AddTorque above to:

 

self.entity:AddTorque(Transform:Vector(torque,self.entity,nil))

 

And it appears to works fine

 

EDIT2: adding forces also results in very bezare results, physics has some real issues going off.

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

I have actually given up until further notice, Its just really getting on my nerves trying to find the issue when its obviously in the core somwhere.

 

I hate having to sound like im moaning, but i have give it anohter 3 - 4 hours this morning trying to get what seems simple torques and forces to act "normal" yet they dont, it feels like you've cracked it then all of sudden the forces go mad and send my objects off on a tagent somewhere, im not doing any special maths or trickery, just simplly adding forces and torques.

 

To me its not useable in any way at the moment so im not wasting any more hours on it until its been looked at.

 

Andy

  • Upvote 1

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Ok, but i dont really get this demo thing? I provided a script in my OP that shows the issue im having, wants the point in zipping up a complete project when all josh needs to do is start leadwerks 3, draw some CSG and add the script? As thats all the demo will be... If anything its a waste of server space?

 

But if thats whats needed then so be it.

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

It is not clear to me what the expected and actual behavior are, and how they differ.

 

This will result in the torque being added as a local rotation value.

self.entity:AddTorque(torque,false)

 

These two lines will produce the same result:

self.entity:AddTorque(Transform:Vector(torque,self.entity,nil),false)
self.entity:AddTorque(torque,true)

 

This is what the Entity::AddTorque function actually looks like internally:

    void Entity::AddTorque(const Vec3& torque, const bool global)
   {
       if (body)
       {
           if (global)
           {
               body->AddTorque(torque);
           }
           else
           {
               body->AddTorque(Transform::Vector(torque,NULL,this));
           }
       }
   }

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Thats exactly the issue though Josh, When you use

self.entity:AddTorque(torque,false)

to an object, it does not rotate around its own local axis?

 

If I use

self.entity:AddTorque(Transform:Vector(torque,self.entity,nil))

then the object appears to rotate correctly around its own axis, even though that doesnt make sense as it is supposidly converting the given vector from local to global....

 

I feel like there alot of defence about this even though this is a bugs forum. There has been quite alot of complaints popped up recently regarding physics and its strange behaviours. All i ask is if you Josh or someone can have a good look into the physics, have a play and see whats going on. It really doesnt take much to see the strange happenings appear.

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

I don't like trying to guess and recreate behavior because it usually leads to me having to ask for an example anyways, or I miss the actual issue the user is describing. The easiest is when a simple one-page example is posted. The code examples in the documentation make a good basis for most of these.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Ok, if really needs be ill post an example, but the example will be a new project, with a CSG box and the script i posted in my OT?

 

Its no real example, it simply shows that torque is not being added locally. And while it hard to show, i belive there is issue going on with AddForce as there was very strange things happeneing whilst i was trying to get things working..

 

But now, i can say as a bug report.

 

AddTroque applys the torque globally regardless to weather you set its paremeter to true or false.

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...