Jump to content

Joint:Ball problem


Recommended Posts

I tested Join:Ball() today and found out a problem with the parent entity

Here is my modified code from https://www.leadwerks.com/docs?page=API-Reference_Object_Joint_Ball

parent = Model:Box() 
parent:SetColor(0.0,0.0,1.0) 
parent:SetMass(0) 
parent:SetPosition(1,0,0) --Move parent box a little bit to the right
parent:SetGravityMode(false) 
        
child = Model:Box() 
child:SetColor(1.0,0.0,0.0) 
child:SetMass(1) 
child:SetPosition(2,0,0) 
child:AddTorque(10,0,0) 

As I expected, the child object's joint position shoud follow the parent object position. but not.

child object's joint position is still at Global position (0,0,0)

Link to comment
Share on other sites

  • 1 year later...

Do this:
 

--Create a window
window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:Move(0,0,-4)
local light = DirectionalLight:Create() 
light:SetRotation(35,35,0) 
        
local parent = nil 
local child = nil 
        
parent = Model:Box() 
parent:SetColor(0.0,0.0,1.0) 
parent:SetMass(0) 
parent:SetPosition(1,0,0) --Move parent box a little bit to the right
parent:SetGravityMode(false) 
        
child = Model:Box() 
child:SetColor(1.0,0.0,0.0) 
child:SetMass(1) 
child:SetPosition(2,0,0) 
child:AddTorque(10,0,0) 
       
local pos = parent:GetPosition(true)
local joint = Joint:Ball(pos.x, pos.y, pos.z, child, parent) 

while true do        
        if window:Closed() or window:KeyHit(Key.Escape) then return false end

        Time:Update()
        world:Update()
        world:Render()
        context:Sync()

end

 

 

 

Link to comment
Share on other sites

  • Admin locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...