The title says it all! I have a dynamic body that when collided with need to stay still…
Thanks!
The title says it all! I have a dynamic body that when collided with need to stay still…
Thanks!
Sorry, but that isn’t actually clear.
Let me see if I can puzzle this out. You have two bodies, A and B.
I will assume they are both ‘dynamic’ bodies.
Body A is stationary. Body B is moving.
Body B hits body A.
If I have this right so far, what do you want to happen?
Do you want body A to not respond to the collision? If so, make body A or B a ‘sensor’.
Note: In most game physics systems, there are two parts to physics collisions:
It sounds like you want no ‘response’.
Ok so yes you have that correct… But what i want is for body A and B to collide … So lets say i have A on the left and B on the right an if A moves and hits B then the rotation is locked(i got that) and it doesn’t move on the y ( like bouncing off ) axis but can move on the x… ( check out the picture i attached )
Thanks!
Will body A ever move away from its horizontal axis? Or should it remain locked to that horizontal axis, like it’s an object that slides across a plane?
Brent
It should remain locked tonthe horizontal axis… It can only move side to side(I use linearVelocity )
Thanks!
OK, well there are a few ways to accomplish this, but I suggest using a piston joint. Imagine this as a joint which basically allows an object to move along a pre-defined axis, and not off that axis. It can also have limits set so that the object won’t slide past certain defined “ends” of the axis.
The one possible “catch” is that you’ll need to join it to another object. This can be whatever… for example, an invisible static sensor so the player doesn’t see it… but you’ll need something to join the sliding object to (or rather, to attach the piston joint to).
https://docs.coronalabs.com/guide/physics/physicsJoints/index.html#piston
Brent
Ok so i got the piston joint working…
Everything works perfect now…
Thanks Brent!
Sorry, but that isn’t actually clear.
Let me see if I can puzzle this out. You have two bodies, A and B.
I will assume they are both ‘dynamic’ bodies.
Body A is stationary. Body B is moving.
Body B hits body A.
If I have this right so far, what do you want to happen?
Do you want body A to not respond to the collision? If so, make body A or B a ‘sensor’.
Note: In most game physics systems, there are two parts to physics collisions:
It sounds like you want no ‘response’.
Ok so yes you have that correct… But what i want is for body A and B to collide … So lets say i have A on the left and B on the right an if A moves and hits B then the rotation is locked(i got that) and it doesn’t move on the y ( like bouncing off ) axis but can move on the x… ( check out the picture i attached )
Thanks!
Will body A ever move away from its horizontal axis? Or should it remain locked to that horizontal axis, like it’s an object that slides across a plane?
Brent
It should remain locked tonthe horizontal axis… It can only move side to side(I use linearVelocity )
Thanks!
OK, well there are a few ways to accomplish this, but I suggest using a piston joint. Imagine this as a joint which basically allows an object to move along a pre-defined axis, and not off that axis. It can also have limits set so that the object won’t slide past certain defined “ends” of the axis.
The one possible “catch” is that you’ll need to join it to another object. This can be whatever… for example, an invisible static sensor so the player doesn’t see it… but you’ll need something to join the sliding object to (or rather, to attach the piston joint to).
https://docs.coronalabs.com/guide/physics/physicsJoints/index.html#piston
Brent
Ok so i got the piston joint working…
Everything works perfect now…
Thanks Brent!