how to move objects?
Forum » General / Help » how to move objects?
Started by: ali (guest)
On: 1258018551|%e %b %Y, %H:%M %Z|agohover
Number of posts: 4
rss icon RSS: New posts
how to move objects?
ali (guest) 1258018551|%e %b %Y, %H:%M %Z|agohover

I really can't figure it out, I used Body.Velocity it does work, but it seems buggy. Also I tried to create Controller and use Body.AddBodyForce(), again fail. Does anyone know how to move Body? if you have working code of this, post it, please.

unfold how to move objects? by ali (guest), 1258018551|%e %b %Y, %H:%M %Z|agohover
Re: how to move objects?
PGlynnPGlynn 1258065800|%e %b %Y, %H:%M %Z|agohover

body.MoveTo(Vector3 position, Matrix orientation);

this should work with a body using collisionskin containing box, sphere, and or capsules

unfold Re: how to move objects? by PGlynnPGlynn, 1258065800|%e %b %Y, %H:%M %Z|agohover
Re: how to move objects?
ali (guest) 1258215308|%e %b %Y, %H:%M %Z|agohover

body.MoveTo(Vector3 position, Matrix orientation); isn't a good method for moving characters in real time, this method "teleports" the object, but I need something that will move objects smoothly.

unfold Re: how to move objects? by ali (guest), 1258215308|%e %b %Y, %H:%M %Z|agohover
Re: how to move objects?
PGlynnPGlynn 1258266932|%e %b %Y, %H:%M %Z|agohover

well it doesnt just teleport. it also wakes up anything resting against it.

if your trying to apply a velocity you might want to make your own body class heres a example based on character body

public class DesiredVelocityBody : Body
        {

            public Vector3 desiredVelocity;

            public override void AddExternalForces(float dt)
            {
                ClearForces();

                Vector3 deltaVel = desiredVelocity - Velocity;

                bool running = true;

                if (desiredVelocity.LengthSquared() < JigLibX.Math.JiggleMath.Epsilon) running = false;
                else deltaVel.Normalize();

                deltaVel.Y = 0.0f;

                // start fast, slow down slower
                if (running) deltaVel *= 10.0f;
                else deltaVel *= 2.0f;

                float forceFactor = 1000.0f;

                AddBodyForce(deltaVel * Mass * dt * forceFactor);

                AddGravityToExternalForce();
            }
        }
last edited on 1258266973|%e %b %Y, %H:%M %Z|agohover by PGlynn + show more
unfold Re: how to move objects? by PGlynnPGlynn, 1258266932|%e %b %Y, %H:%M %Z|agohover
New post
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License