EntityRotator and EntityMover Versus Manually Doing It

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Garold
Posts: 60
Joined: Fri Sep 23, 2011 5:17 pm
Location: Liverpool, England

EntityRotator and EntityMover Versus Manually Doing It

Post 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.
BEPUphysics rules my world
http://cloneofduty.com
Garold
Posts: 60
Joined: Fri Sep 23, 2011 5:17 pm
Location: Liverpool, England

Re: EntityRotator and EntityMover Versus Manually Doing It

Post 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.

BEPUphysics rules my world
http://cloneofduty.com
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: EntityRotator and EntityMover Versus Manually Doing It

Post 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.
Garold
Posts: 60
Joined: Fri Sep 23, 2011 5:17 pm
Location: Liverpool, England

Re: EntityRotator and EntityMover Versus Manually Doing It

Post by Garold »

Ah! OK. Thanks. I'll get on with it.
BEPUphysics rules my world
http://cloneofduty.com
Garold
Posts: 60
Joined: Fri Sep 23, 2011 5:17 pm
Location: Liverpool, England

Re: EntityRotator and EntityMover Versus Manually Doing It

Post 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.

BEPUphysics rules my world
http://cloneofduty.com
Post Reply