Page 1 of 1

Move EntityMesh

Posted: Sat Feb 05, 2011 12:40 am
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.

Re: Move EntityMesh

Posted: Sat Feb 05, 2011 1:03 am
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.

Re: Move EntityMesh

Posted: Sat Feb 05, 2011 1:10 am
by konserwa
Maybe some simple or something like that?

Re: Move EntityMesh

Posted: Sat Feb 05, 2011 1:22 am
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.