Jump to content

physics rotation


wildcherrii
 Share

Recommended Posts

Since my last few problems went unanswered, i assume no one knows the answer or its just some broke stuff in le, who knows. Im faced with a new problem now, possibly my last problem if I cannot get it solved.   Im try to place an object, in this case a beach ball, on the map in my player hand. The beach ball is a prefab with a phycs rigid body since I need the collision data.  Everything so far I described is fine, but here what I cannot figure out.  Once i get the ball into the scene how do I rotate the ball to match my players rotation. If i use standard setrotation  then i break physics. I need a starting orientation for this damn beach ball then i can apply velocity or force or whatever to make it go forward.

This engine has been  out for 12 yrs now, surely somehow a way to load a physics entity and set a starting rotation has be resolved?

 

This is what i came up with so far 

    local item=Model:Load("Models/Misc/damnbeachball.mdl")
    local pos = glo.player:GetPosition()
    item:SetMass(0)
    item:SetPosition(pos)
    item:SetRotation(glo.player:GetRotation())
    item:Move(0,.3,-.2)    --- line up to his hand // bone local seems to be off and i cannot find any damn Tformvector commands in le
    item:SetMass(1)
    item:SetVelocity(0,0,-10,false)

Link to comment
Share on other sites

I could understand if this was a laser cube like in Portal 2, but why do you need the ball to rotate? You should be getting the vector of the player direction with Transform:Vector and applying velocity based on that.

Going from your code, try:

local item=Model:Load("Models/Misc/damnbeachball.mdl")
local pos = glo.player:GetPosition()
item:SetMass(0)
item:SetPosition(pos)
--item:SetRotation(glo.player:GetRotation()) -- < You can possibly use PhysicsSetRotation, but it's a deprechated command.
item:Move(0,.3,-.2)    --- line up to his hand bone local seems to be off and i cannot find any damn Tformvector commands in le
item:SetMass(1)
--item:SetVelocity(0,0,-10,false)

-- Throw the object way from the player
local force = Vec3(0,0, 10) 
local v = Transform:Vector(force, glo.player, nil)
item:AddForce(v)

Not sure what kind of game you're trying to make but you should be loading that model once on Start() and then instancing that reference. Don't call Model:Load during runtime or else you'll have hitches. 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

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...