Moving an Object around

I am trying to move an object ( to be exact Oto from the examples ) around. Or better said i want him to walk around. The animation is not the problem… Its more that he doesn’t react on collision if i use motion path to move him around.



i made a class (MyCustomObject.java it extends RigidBodyControl) for his attributes:

[java]

public MyCustomObject(int health, float speed, float mass, AssetManager manager) {

this.health = health;

this.speed = speed;

this.mass = mass;

model = manager.loadModel(“Models/Oto/Oto.mesh.xml”);

model.setLocalScale(0.5f);

model.setShadowMode(ShadowMode.CastAndReceive);

createModel_phy();;

createPath();



}



private void createModel_phy() {

CapsuleCollisionShape capsule = new CapsuleCollisionShape(1.5f, 2f);

character = new CharacterControl(capsule, 0.01f);

this.setCollisionShape(capsule);

model.addControl(this);

this.setPhysicsLocation(new Vector3f(-140, 9, -10));

motionControl.play();

}



private void createPath() {

path = new MotionPath();



path.addWayPoint(new Vector3f(-140, 9, -10));

path.addWayPoint(new Vector3f(-140, 9, -30));



motionControl = new MotionTrack(model, path);

motionControl.setDirectionType(MotionTrack.Direction.PathAndRotation);

motionControl.setRotation(new Quaternion().fromAngleNormalAxis(0, Vector3f.UNIT_Y));

motionControl.setInitialDuration(10f);

motionControl.setSpeed(speed);





}[/java]



And that’s how i create him in my Main method:



[java]

MyCustomCreep mCC = new MyCustomCreep(100, 1, 2, assetManager);

rootNode.attachChild(mCC.getModel());

getPhysicsSpace().add(mCC.getModel());

[/java]



As long as i don’t move him he “collides” but as soon as i let him walk around (by “playing” the motionControl) he literally walks through walls.

Is there a better way to let him move then creating a path? or what am i doing wrong?



If you need more code just ask. i tried to shorten it to the relevant…

You cannot use animation paths on characters, make it a kinematic RigidBody for that or use the new KinematicRagdollControl.

1 Like

Yeah the MotionTrack does not support physic enabled objects, maybe there should be something special for the character control that only change the walkingDirection of the characterControl according to the path…

hmm would be nice… But anyway with your hint i got it working now and its still very convenient :slight_smile:

I really appreciate your work (and your help :slight_smile: )



Let’s see if i can implement an A* algorithm for pathfinding…