Hello,
I'd like to include an object in my scene which is capable of being depressed, and recognizing when it is, like a button.
This would be similar to the pads found in Portal or Quantum Conundrum, where an object can be placed on a button, and it triggers another action.
I tried using the example included in Jitter with the two objects and the joint. I made the boxes have a bigger surface area, narrower, the bottom one became static, and the mass of both was reduced significantly. After some tweaking it worked to a degree, but it behaved more like a trampoline. Maybe that's my material settings?
If there is nothing on the pad I'd like it to stay 1 unit above the bottom pad. When an object presses on the upper pad, it is pressed down one unit and hits pad 2. Upon removing the object, pad 1 returns to 1 unit above the bottom pad.
Any ideas?
This is the code I have, you could dump it into your PrismaticJointTest.cs scene from the demo.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jitter.Collision.Shapes;
using Jitter.Dynamics;
using Jitter.LinearMath;
using Jitter.Dynamics.Joints;
namespace JitterDemo.Scenes
{
public class PrismaticJointTest : Scene
{
public PrismaticJointTest(JitterDemo demo)
: base(demo)
{
}
public override void Build()
{
AddGround();
RigidBody body1 = new RigidBody(new BoxShape(5, 0.125f, 5));
RigidBody body2 = new RigidBody(new BoxShape(5, 0.125f, 5));
body1.Position = new JVector(0, 1.125f, 0);
body2.Position = new JVector(0, 0.125f, 0);
body1.Mass = 0.1f;
body2.Mass = 0.1f;
body2.IsStatic = true;
PrismaticJoint pj = new PrismaticJoint(Demo.World, body1, body2, 1f, 2f);
pj.MaximumDistanceConstraint.Softness = 0.0f;
pj.MinimumDistanceConstraint.Softness = 1.0f;
pj.Activate();
Demo.World.AddBody(body1);
Demo.World.AddBody(body2);
}
}
}
