Move EntityMesh

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
konserwa
Posts: 3
Joined: Sat Feb 05, 2011 12:34 am

Move EntityMesh

Post by konserwa »

when i use normal move

Code: Select all

          if (keyboardstate.IsKeyDown(Keys.Up))
            {
                lol.Y--; //Lol is Vector3
                enity.WorldTransform = Matrix.CreateTranslation(lol);
            }
model is not subject to collisions.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Move EntityMesh

Post by Norbo »

Correct. Setting the position teleports the object. It doesn't matter what is at the teleport destination; the object will happily comply and teleport into anything else. You may notice a somewhat 'gooey' response as the system uses penetration recovery to push the objects apart, but that will be completely overridden if more teleport commands are issued.

In order to allow collision response to occur, entities should be controlled with forces or velocity changes.
konserwa
Posts: 3
Joined: Sat Feb 05, 2011 12:34 am

Re: Move EntityMesh

Post by konserwa »

Maybe some simple or something like that?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Move EntityMesh

Post by Norbo »

If you're wanting an example, here's a tiny modification to the original example which would obey collisions:

Code: Select all

            if (keyboardstate.IsKeyDown(Keys.Up))
            {
                enity.InternalLinearVelocity = new Vector3(0,1,0);
            }
Now, when Up is pressed, the entity's velocity will make it go up. If you're trying to control a character or something, you could try summing up the various movement velocities from user input and setting that sum to the entity's linear velocity.
Post Reply