I have another little problem. I don't know if I have to open a new thread with the new question.
I created a world with 4 walls, now I implemented the erratic movement following your previous topic, and with great pleasure I notice how the my object collides with the 4 walls.
Now I have created a Slice sensor body, so to disallow collision events. I want this Slice to be jointed to my previous object, like a bidimensional showcone. I use a WeldJoint, but now the object doesn't move anymore.
So I try to access to the object through the WeldJoint
Code: Select all
@Override
public void end(Step arg0, World arg1) {
Random r = new Random();
for (Joint joint : body.getJoints())
{
Vector2 v = joint.getBody1().getLinearVelocity();
if(r.nextBoolean())
v.x = v.x + r.nextFloat() * 5;
else
v.x = v.x - r.nextFloat() * 5;
if(r.nextBoolean())
v.y = v.y + r.nextFloat() * 5;
else
v.y = v.y - r.nextFloat() * 5;
joint.getBody1().setLinearVelocity(v);
}
}
On this way I move again my object with the jointed showcone....but....he passes through the walls.
I try to create other bodies in the world, my object collides with them, them collide and bounce on the walls, but my primary object doesn't collide with walls. This behaviour happens because changing the velocity directly isn't recommended or did I do something wrong?
To follow your advice to use the MotorJoint I need two object and move the second erratically so the first try to follow him?
Thanks and please, forgive me for the hassle.
EDIT: I don't know how ....but now it works