I’ve been playing with values for what seems like forever for my vehicle, but I’m not seeming to get realistic results from it. I drive up hills, but the vehicle slows, stops, then rolls backward. I can’t make it up the hills unless I’m speeding through them, which isn’t what I’m going for at all. I’m looking for a slow, powerful smooth movement like a tank, but my results look more like matchbox cars. Also, I’m not looking for a slow visible acceleration to full speed, I’d like it to be motor is on or off at full speed (actrually rather slow, again think of a tank).
Any ideas what I can do? I’ve read the notes on the wiki here as well as the external suspension notes linked therein. I can’t seem to find an answer.
The brake value? You can use brake and acceleration at the same time. Or you combine them going from brake->acceleration->brake when the user presses the accelerate button.
Edit: Also, did you play with the mass? I am getting pretty slow and heavy vehicles when I increase the mass.
Edit 2: Otherwise you can simply create your own “car” with hinge joints, you’ll have more control over that than over the RayCast car
Well, I’m looking to make it autonomous, so I won’t have to press any buttons on this character. I’m actually modeling this robot except instead of having articulating joints, I’m modeling it as a block with wheels. But notice how powerful it is, that’s what I’m going for. That robot would never “roll” on its own, the gears are too hard to turn unless they are powered. I’m just not getting that sense of power from the model I’m using.
–Quick edit. I’m also noticing the acceleration is slow in the beginning, which is also unlike the actual robot.
Yeah, see my edit 2, you can just model the car from joints etc. But I’d try the brake solution first.
I’ll look into the joint setup. I didn’t think of that for some reason. Thanks, and thanks for the quick replies!
I realize it has been AGES since this thread was active, but I finally got around to messing with HInge/Joint motors. I am having a problem controlling the motor with in the following code. I can only control the motor if I begin pressing the “motor activate” buttons before the screengraph loads (as I had read in a previous post, I have to send commands to the motors quickly or else they will become deactivated. My problem is that I don’t have very good control over the motor. Pressing the spacebar does not stop the motor as I would have expected.
My questions are:
–Is there a way to reactivate the joint if it takes too long to start? (I don’t want the vehicle to be driving as soon as the screengraph starts).
–Is there a way to stop the motor with either a coast or braking result?
The code is below, any help would be greatly appreciated.
[java]/*
- Copyright © 2009-2010 jMonkeyEngine
- All rights reserved…
- …
*/
package Tests;
import jme3test.bullet.PhysicsTestHelper;
import com.jme3.bullet.BulletAppState;
import com.jme3.app.SimpleApplication;
import com.jme3.bullet.PhysicsSpace;
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.collision.shapes.CylinderCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.joints.HingeJoint;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
public class TestPhysicsHingeJoint extends SimpleApplication implements AnalogListener {
private BulletAppState bulletAppState;
private HingeJoint joint;
public static void main(String[] args) {
TestPhysicsHingeJoint app = new TestPhysicsHingeJoint();
app.start();
}
private void setupKeys() {
inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping("Swing", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(this, "Left", "Right", "Swing");
}
public void onAnalog(String binding, float value, float tpf) {
if(binding.equals("Left")){
joint.enableMotor(true, 1, .1f);
}
else if(binding.equals("Right")){
joint.enableMotor(true, -1, .1f);
}
else if(binding.equals("Swing")){
joint.enableMotor(false, 0, 0);
}
}
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
setupKeys();
setupJoint();
}
private PhysicsSpace getPhysicsSpace(){
return bulletAppState.getPhysicsSpace();
}
public void setupJoint() {
Node holderNode=PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .1f, .1f, .1f)),0);
holderNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f,0,0f));
rootNode.attachChild(holderNode);
getPhysicsSpace().add(holderNode);
// Node hammerNode=PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f( .3f, .3f, .3f)),1);
Node hammerNode=PhysicsTestHelper.createPhysicsTestNode(assetManager, new CylinderCollisionShape(new Vector3f(0.1f,0.3f,0.3f),0),1);
hammerNode.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0.3f,0f,0f));
rootNode.attachChild(hammerNode);
getPhysicsSpace().add(hammerNode);
joint=new HingeJoint(holderNode.getControl(RigidBodyControl.class), hammerNode.getControl(RigidBodyControl.class), Vector3f.ZERO, new Vector3f(-0.3f,0f,0f), Vector3f.UNIT_X, Vector3f.UNIT_X);
getPhysicsSpace().add(joint);
}
@Override
public void simpleUpdate(float tpf) {
}
}[/java]
a) You can activate RigidBodies using setActive()
b) Use the same rotational joint you use for acceleration?
a)Would this mean I have to declare RigidBody objects instead of the “RigidBodyControl.class” calls?
b) There is only 1 joint in the program, I am setting it to (false,0,0); which should stop the motor correct?
The goal is to make a vehicle with a 2-wheel differential drive type and a 3rd “free” wheel like what is shown here. Do you have any suggestion on how to make the 3rd wheel glide smoothly over the terrain?
a) You misunderstand that completely. When you specify a class in getControl(), you basically say “give me the first control object in this spatial that has this class”.
b) Disabling the motor will make it dangle
c) I’d do it using a HingeJoint