Bepu v2 Character Controllers

Discuss any questions about BEPUphysics or problems encountered.
parapoohda
Posts: 49
Joined: Fri May 31, 2019 6:30 am

Re: Bepu v2 Character Controllers

Post by parapoohda » Tue Jul 30, 2019 4:49 am

Thank you. It work. Is it magic? How could it work :lol: :lol:

parapoohda
Posts: 49
Joined: Fri May 31, 2019 6:30 am

Re: Bepu v2 Character Controllers

Post by parapoohda » Wed Jul 31, 2019 9:24 am

Is view direction is rotational direction of object? I munipulate target velocity(x-y) but I can't pair vector 2 to 2/3 axis of vector3.
If i change view direction it also shuffle pair of x or y to vector3. I can't pair x of vector2 to x of vector3 and y of vector2 to z of vector3.
How can I use bepu with bird eye view. Should i pair x to x and -y to z in view direction (0,0,-1)?

Norbo
Site Admin
Posts: 4737
Joined: Tue Jul 04, 2006 4:45 am

Re: Bepu v2 Character Controllers

Post by Norbo » Wed Jul 31, 2019 5:46 pm

View direction is sorta-kinda rotational direction. It is the starting point from which a frame of reference is created. It is projected down onto the surface that currently supports the character to create the 'forward' direction, and then the character's up direction and that computed forward direction are used to compute the 'right' direction.

A target velocity of (1,0) will try to move along the positive 'right' direction at a speed of 1, while a target velocity of (0, 1) will try to move along the positive 'forward' direction at a speed of 1.

It's a bit redundant for a top down game, so you have a couple of options:
1) Arbitrarily choose the view direction, and then just assign the movement direction in ways that accomplish the motion you want.
2) Always set the target velocity to (0,desiredSpeed) and then set the 3d view direction in the direction you want the character to move.

There is no single 'correct' way to do this, it's just arbitrary, so pick whatever is easiest.

parapoohda
Posts: 49
Joined: Fri May 31, 2019 6:30 am

Re: Bepu v2 Character Controllers

Post by parapoohda » Thu Aug 01, 2019 2:26 am

Oh thank you. I think i will try second option.

parapoohda
Posts: 49
Joined: Fri May 31, 2019 6:30 am

Re: Bepu v2 Character Controllers

Post by parapoohda » Sun Aug 04, 2019 12:34 am

I have 3 problem.

1 I tried option 1 that fix view direction axis. In main project it move correctly for a second before change direction. I try to build stand alone for you to look at. But not success to replicate problem. So today and maybe tomorrow I will try to replicate problem.

2 I in update character goal it have

Code: Select all

Debug.Assert(characterBody.Awake, "Velocity changes don't automatically update objects; the character should have already been woken up before applying air control.");
which It throw error. It think it is because support is false. But what is bool support mean?

3 I tried to console writeline handle
So in cogufigure manifold i print

Code: Select all

Console.WriteLine(pair.A.Handle);
Console.WriteLine(pair.B.Handle);
But it show 0 is it working correctly. And also when add to simulation I tried to print handle but it show nothing

_(_ _) _ Thank you. I don't know what to say to appreciate your help

Norbo
Site Admin
Posts: 4737
Joined: Tue Jul 04, 2006 4:45 am

Re: Bepu v2 Character Controllers

Post by Norbo » Sun Aug 04, 2019 1:25 am

It think it is because support is false. But what is bool support mean?
Support means the character is standing on something. That assert is meant to protect against modifications to the velocity when the character is asleep, since directly modifying velocities does not automatically wake bodies up. In the original version of that function, there's a section before the air control block that ensures the character is awake if anything relevant about the control state has changed.
But it show 0 is it working correctly. And also when add to simulation I tried to print handle but it show nothing
Printing zero may be correct- handles can be zero, and it's possible that a body with a handle of 0 is colliding with a static with a handle of 0. Bodies and statics can have overlapping handle values since they refer to different systems (similar to how constraint handles can overlap body or static handles).

parapoohda
Posts: 49
Joined: Fri May 31, 2019 6:30 am

Re: Bepu v2 Character Controllers

Post by parapoohda » Sun Aug 04, 2019 3:40 am

Thank you.

parapoohda
Posts: 49
Joined: Fri May 31, 2019 6:30 am

Re: Bepu v2 Character Controllers

Post by parapoohda » Wed Aug 07, 2019 6:22 am

After stan alone it seem player fall flat to the ground. I will post link to stand alone if I see it upload. Maybe I done something wrong with github.
update

this is stand alone

https://github.com/parapoohda/Why-it-is-fall-flat

Norbo
Site Admin
Posts: 4737
Joined: Tue Jul 04, 2006 4:45 am

Re: Bepu v2 Character Controllers

Post by Norbo » Wed Aug 07, 2019 6:34 pm

Nothing is stopping the body from falling over, so it does. For characters, a common approach is to set the inverse inertia to all zeroes; this gives it effectively infinite rotational inertia and it can't be rotated by any force anymore. So, in your AddCharacter function:

Code: Select all

            var characterShape = character.Shape();
            characterShape.ComputeInertia(1, out var characterInertia);
            characterInertia.InverseInertiaTensor = default;
            int handle = Simulation.Bodies.Add(BodyDescription.CreateDynamic(character.GetStartPosition(), characterInertia, new CollidableDescription(Simulation.Shapes.Add(characterShape), 0.1f), new BodyActivityDescription(0.01f)));
Setting characterInertia.InverseInertiaTensor = default stops the character from falling.

Any other approach can work too- if you did want the character to rotate sometimes, using a constraint or velocities to control its orientation could work.

parapoohda
Posts: 49
Joined: Fri May 31, 2019 6:30 am

Re: Bepu v2 Character Controllers

Post by parapoohda » Thu Aug 08, 2019 4:22 am

You are avery helpful. Thank you.

Post Reply

Who is online

Users browsing this forum: No registered users and 54 guests