Jump to content

Collision without physics?


X54321
 Share

Recommended Posts

ANSWERED

 

Hi, I just bought this engine a couple of days ago. It's really nice so far, but the physics engine is kind of glitchy. There have been other posts on the physics engine, and so I am aware the developer is working on it. BUT, the game I am looking to make doesn't need any sort of physics; I just need collision. Unfortunately, I can't seem to collide with anything if the mass is set to 0. If I enable physics, I can't seem to get it to not move, and It goes through everything. SO, does anyone have an idea?

 

*EDIT: I am using a rigid body character, not a character controller.

Link to comment
Share on other sites

I know it will take a while but I'm really curious what you come up with. One of my inspirations is another Leadwerks 2.5d platformer: http://www.leadwerks.com/werkspace/files/file/278-the-last-chapter/

You probably can't download it as it was an LE2 project but take my word that it's pretty cool.

The other bigger one is Trine / Trine 2 but that involves physics and control that I don't think Leadwerks can do yet.

Link to comment
Share on other sites

Ok, so it turns out that method had a lot of collision bugs. I then came up with a new solution that uses the physics, and it (almost) works, but it is really weird. The physics for the player are so jittery it makes the game virtually unplayable. I don't think it's lag, either, because the frame rate is about 180! I'll put up the project in a moment; It'll take a while to upload.

Link to comment
Share on other sites

Your call to SetRotation() is resetting the entity physics each frame, and it's also called in UpdateWorld() instead of UpdatePhysics(), where it should be (if at all): I changed the command to PhysicsSetRotation() which will do the same thing by applying torque to the object.

local window = Window:GetCurrent()

 

local onGround = false

 

function Script:Start()

x = self.entity.position.x

y = self.entity.position.y

z = self.entity.position.z

end

 

function Script:UpdatePhysics()

 

window = Window:GetCurrent()

 

if window:KeyDown(Key.D) and not cRight then

self.entity:SetVelocity(Vec3(10, self.entity:GetVelocity().y, 0))

elseif window:KeyDown(Key.A) and not cLeft then

self.entity:SetVelocity(Vec3(-10, self.entity:GetVelocity().y, 0))

end

 

if window:KeyDown(Key.W) and onGround then

self.entity:AddForce(0,500,0,true)

end

 

--self.entity:SetRotation(0, 0, 0)

self.entity:PhysicsSetRotation(0, 0, 0)

self.entity.position.z = -6.0

 

onGround = false

end

 

function Script:Collision( entity, position, normal, speed )

 

--print(normal.y)

 

if normal.y > 0.0 then

onGround = true

end

 

end

 

You will always have problems if you try to make a rigid body behave like a character controller, because a character controller is fundamentally unrealistic...it always points straight up and down and can't rotate around the XZ axes. Even if you use a force to try to change the orientation, that force will have other unintended effects.

 

The character controller is specifically designed for this type of movement and should really be used here. There are previous projects that used it in this way.

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

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