Jump to content
Leadwerks Community

Recommended Posts

Posted

Hello again,

 

Once more, I'm having some issues with the collision system. I have an object in my game that I want to have bouncing back and forth between the map walls that will act as an obstacle for the player character. I cannot use a physics object for this, as it makes the object's behavior inconsistent and difficult to control after its first collision. However, with its Mass set to 0, it no longer registers collisions with the map walls. It will collide with a player character (which is a physics object) and react as it is supposed to, just not with the walls or any other non-physics object placed in the scene.

 

What can I do to correct this and have it register collisions with non-physics objects?

 

Thanks!

 

 

 

I don't think it is helpful, but I have included the object's settings and script below, just in case.

Settings:

Physics Mode: Rigid Body

Collision Type: Character (I have tried every available type and none of them solve this issue.)

Mass: 0

Character Angle: 0

Swept Collision: False

Nav Obstacle: False

 

Script.moveSpeed = 5.0 --float "Movement Speed"
Script.initDir = -90 --float "Initial Direction"

function Script:Start()

   self.entity:SetRotation(0, self.initDir, 0, true)
   self.entity:SetMass(0)
   dirFlip = 1

end


function Script:UpdateWorld()

   self.entity:Move(0, 0, self.moveSpeed * dirFlip, false)

end


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

   dirFlip = dirFlip * -1

end

Posted

Add

 

self.entity:SetGravityMode(false)

 

in your start function and set your mass to 10. This will make your object collide with the walls.

 

Unfortunately the ball starts going all over the place after hitting the walls twice. Don't know whats going on I'll check again tomorrow once I've had some sleep.

Posted

Moving objects with SetPosition or Move will break Physics simulation. What if you give it a mass, set collision to Trigger so it doesn't bounce itself and then control it's movement with PhysicsSetPosition?

  • Upvote 1

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.

×
×
  • Create New...