This project has moved and is read-only. For the latest updates, please go here.

circles are not bouncing [solved]

Apr 6, 2011 at 6:56 PM


I want my bodies to bounce when they hit something. But they don't. I tried adjusting the Restitution's (Engine.Bounciness) value to 0.5f, 0.8f, float.maxvalue, 0f, but it didn't work.
My ball class:

public Ball() { Vector2 location = ConvertUnits.ToSimUnits(100f,100f);  Body = BodyFactory.CreateCircle(Engine.World, ConvertUnits.ToSimUnits(Radius), 1f, location); Body.BodyType = BodyType.Dynamic; Body.Restitution = Engine.Bounciness; // bounce ability //Body.Inertia = float.PositiveInfinity; // prevent rotation const int ForceNr = 20; Body.ApplyForce(ConvertUnits.ToSimUnits(new Vector2(Maths.RandomFloat(-ForceNr, ForceNr), Maths.RandomFloat(-ForceNr, ForceNr)))); }


My wall class:


    public class Wall
        public Body Body;
        public Wall(Vector2 topLeftLocation, int width, int height)
            Body = BodyFactory.CreateRectangle(Engine.World, ConvertUnits.ToSimUnits(width), ConvertUnits.ToSimUnits(height), 1f, ConvertUnits.ToSimUnits(new Vector2(topLeftLocation.X + width / 2, topLeftLocation.Y + height / 2)));
            Body.Restitution = Engine.Bounciness; // bounce ability
            Body.IsStatic = true;


Now when I apply a force to the ball and make it hit a wall the ball will not bounce but will instead follow the wall or it will completely stop. I uploaded a picture of the problem:


Apr 7, 2011 at 2:03 PM

Solved, I changed the _displayUnitsToSimUnitsRatio from something like 3000 down to 100. After that it worked.