Inconsiderate rigidbodies

Hello! So I have a bit of a problem… basically, I have an “AI” (very very rudimentary but still working) which constantly moves towards the player! Here’s the code for it, by the way:

[java]
Vector3f offset = cam.getLocation().subtract(AI.getWorldTranslation());
Vector3f direction = offset.normalize();
AI_phys.setPhysicsLocation(offset.divide(1000).add(AI_phys.getPhysicsLocation()));
//AI is a spatial imported with the import tool…
[/java]

Now, this work great, and the AI moves slowly (hence the 1000 dividing) towards the player since this is in the update loop (well, not the creation of new vectors each frame, that’s just to make it clear).

However, here’s the catch: The physics body of the AI simply ignores all other physics, and passes through walls. Now, this also happens if I set the physics to be kinematic and spatial.move(…) instead, so it’s not just because of the moving of the physics. I kind of expect this behavior if I literally just force it to move forward, but is there any neat way to solve this problem? Charactercontrol, perhaps, and setting walkdirection? I tried it at first but got a bit stuck, so any help is appreciated! Thanks!

Potentially helpful translation of your question:
“Why is it that when I teleport my object it gets teleported through walls?”

Hint: don’t teleport it. Apply forces to the rigid body instead.

@pspeed said: Potentially helpful translation of your question: "Why is it that when I teleport my object it gets teleported through walls?"

Hint: don’t teleport it. Apply forces to the rigid body instead.

Well, my question was not why does my object teleport, but rather, "It teleports, as it “should”. What is a workaround for this, potentially using other mechanics.

Forces are a perfect solution, it seems like! I’ll try it out asap! :slight_smile: