Page 1 of 1

EntityRotator and EntityMover Versus Manually Doing It

Posted: Sun Nov 25, 2012 6:30 pm
by Garold
Hi,

I have a helicopter that the character spawns inside. I've been calculating a path and evaluating this path for the EnityMover and EntityRotator. That approach works fine. When the helicopter moves or rotates the character rotates with it and stays within the helicopter interior.

I have recently being working on a more "flexible" method, as I'd like the helicopter to hug the terrain more and avoid obstacles along the way. I've made the helicopter kinematic, I move it by adjusting its LinearVelocity and I rotate it by calculating a new quaternion for the Body.Orientation based on the helicopter's Yaw.

The problem I have is the character will not collide properly with the inside of the helicopter and will fall out if the helicopter turns too quickly. I have a damage system that, I had to switch off, (it checks info.NormalImpulse of a Pair.Contact) as it was being triggered when the helicopter moved.

I must be doing something very wrong :)

Is the problem caused by me manually messing with LinearVelocity and Orientation, should I be using a different approach?

Thanks.

Re: EntityRotator and EntityMover Versus Manually Doing It

Posted: Sun Nov 25, 2012 7:57 pm
by Garold
From looking at another post I decided to add this code. It didn't fix it though

Code: Select all

Body.ActivityInformation.IsAlwaysActive = true;
Body.PositionUpdateMode = PositionUpdateMode.Continuous;
I've made a private video: When arriving in the first helicopter, all the collisions are fine, this helicopter is moved by an EnityMover. The second helicopter does not keep the character inside, it is rotated by adjusting the Body.Orientation quaternion and moved by adjusting LinearVelocity.


Re: EntityRotator and EntityMover Versus Manually Doing It

Posted: Sun Nov 25, 2012 9:35 pm
by Norbo
Setting Orientation directly is a form of teleportation, just like setting Position. Instead, use velocities to control the object. You can either start calculating your own AngularVelocity like you do with the LinearVelocity, or you can just use the EntityRotator which does it for you.

Re: EntityRotator and EntityMover Versus Manually Doing It

Posted: Sun Nov 25, 2012 9:44 pm
by Garold
Ah! OK. Thanks. I'll get on with it.

Re: EntityRotator and EntityMover Versus Manually Doing It

Posted: Mon Nov 26, 2012 2:11 am
by Garold
Thanks Norbo, how simple to fix, when you know how! :)

Code: Select all

orientation = Quaternion.CreateFromAxisAngle(Vector3.Up, Yaw);
rotator.TargetOrientation = orientation;
Here's a video of it in action, with a few more changes applied.