Kinematic body examples

Is there some Kinematic physics examples , for example moving some physics cube , all collision handled by physics , but movement handled by code ?

The first and third person templates work that way .

Wasn’t them RigiBody instead ? Because the scripts use Velocity that is RigidBody physics only.
While a Kinematic does not have velocity, forces or torque it’s a physics volume with collision that can only be moved by changing it’s position and rotate applying a rotation.
I’m not sure there is Kinematic support in Blender.

when you move the player around you are not using velocity you are simply translating the object by a certain amount set in the character controller. However you can still interact with physics objects in the scene. Am I missing what you want to accomplish?

Those templates use RigidBodies for the player, not Kinematic.
MagicLord is probably looking for the KinematicCharacterController. I’m guessing you’ll have to make a Trait that inherits from KinematicCharacterController and add it to your player. Haven’t used it yet, so I’m not sure how it works (and I can’t find an example that uses it).

I was refering to physics.
3D engines allow you to define as physics object as RigidBody or Kinematic.
Kinematic means it has collision and interacts with otehr physics objects , but the object movement is driven by code like object translation or rotation, and it’s not driven by physics forces or torque.

You are right, perhaps i should look to the KinematicCharacterController that can be used for any non character object that is Kinematic.

Let me know if you get this working, I managed to get a kinematic object that can move around, but it has trouble climbing ramps, and it’s always buried like 10% into the ground.

Are you using a Collider over the top of the moving object to control the physics interactions? if so move the collider up and that should even out the moing object. I hope that makes sense?

I was able to create a kinematic character just by extending the KinematicCharacterController:

package player;

import haxe.Log;

class PlayerController extends armory.trait.physics.bullet.KinematicCharacterController {
#if arm_bullet
	public function new() {
		super();
	 }
#end
}

After that I used nodes to call setWalkDirection() ( requires function nodes from the git version of Armory ).

Overall I think it works pretty well, but it might need some tweaks. The KinematicCharacterController is actually just a binding to a controller in Bullet so it would probably be useful to rewrite it in Haxe so it could be tweaked for different games.

1 Like

Use dynamic with constraints is the way to go according to this post.
https://stackoverflow.com/questions/42782748/collision-between-kinematic-bodies-in-bullet-physics

This is what i use to make kinematic

Reading Maya doc, it seems there is Kinematic Body
https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-F8C301AE-B746-4522-806F-27F2BC91C8B3-htm.html

There are three types of Bullet rigid bodies:

  • Dynamic rigid bodies (Body Type > Dynamic Rigid Body) are fully simulated physics objects. This type is the most performance intensive rigid body. By default, all rigid bodies are created as Dynamic rigid bodies.
  • Kinematic rigid bodies (Body Type > Kinematic Rigid Body) can be animated during the physics simulation, but they are not affected by the simulation itself. Because kinematic bodies can be moved, the Bullet physics simulation spends more time updating kinematic rigid bodies than static rigid bodies.
  • Static rigid bodies (Body Type > Static Body) do not move during the physics simulation. The Bullet physics simulation can optimize how it updates static rigid bodies in the scene since it knows their positions remain fixed between frames.

We should not need to use a work around.

Yeah, I was doing a little bit of looking around on the Bullet forums. I’m not too sure about using true kinematic bodies where you have to write all of the interaction code yourself. It seems like a lot of work and like you would have to know a lot about the system. I wouldn’t call it a work-around; it is a valid way to accomplish the problem if that is what you need and you know how to do it, but it may be more work than is necessary.

I’m going to try using dynamic objects with constraints instead and see how well that works out.

1 Like

This is not the purpose of physic engine to write all yourself.
Good luck with your kinematic physics :sweat_smile:

Set object physics to dynamic, use translate and rotate to make it kinematic.
Cancel velocity and torque when needed setting their values.

I know this is an old thread, but I’m having some trouble trying to get the KinematicCharacterController to work, I created a class that extends the KinematicCharacterController but I’m unable to move the object that has the trait, @zicklag how did you make it work?

Does it require to have rigid Body or it should work without it? Do I need any additional trait?

I noticed I can call the functions but calling setWalkDirection doesn’t move the object with the trait at all.

Here is minimal project, https://gofile.io/?c=kRgs2d, the forum doesn’t accept zip file so I had to upload it somewhere else.

It sounds like you are doing what I did. I don’t know what would be wrong. I’m pretty sure you don’t make that object a rigid body. I think that would break it. There shouldn’t be any additional traits that you need as far as I remember. Is the object falling according to gravity?

Nope, the object remains static even on “air”, doesn’t fall or move at all. I noticed I also couldn’t modify the object position through the Properties inside the debug panel. This is in Linux Krom

You didn’t happen to set animated = true in the constructor did you? Oh, and are you running super() in your child class’s new() function?

Here is the code,

package arm;

import iron.math.Vec4;
import iron.system.Input;
import iron.system.Time;
import iron.system.Audio;
import armory.trait.physics.KinematicCharacterController;

class Character extends KinematicCharacterController {
#if (!arm_physics)
	public function new() { super(); }
#else
	public function new() {
		super();
		notifyOnInit(function() {
			notifyOnUpdate(update);
		});	
	}

	function update() {
		setWalkDirection(new Vec4(0,100,0));
        trace("test");
	}

}
#end

Hmm, that’s strange. You can see “test” printed in the console on update, too, right?

The post above literally shows the entire PlayerController.hx file that I used. So I don’t know what went wrong. I’m sorry I can’t test your example, I don’t have the Armory SDK installed right now.

Maybe just try putting it on a fresh object?

Oh, another thought, do you have any other rigid bodies in the scene that are working?

Yes, calling other functions that return information seem to work, like getMaxSlope, onGround, and the ones that do the movement don’t seem to affect the object that has the trait, although onGround seems to report always true.

I don’t have any rigid body in the scene.

I have a minimal project to test this