How can I make player detector not affect by gravity
-
- Posts: 92
- Joined: Fri May 31, 2019 6:30 am
How can I make player detector not affect by gravity
I want to use collision to make player detector for player and monster.
Now I can make it not collide with other collidable by make this function
AllowContactGeneration
return false
And not affect by gravity by
make function in DemoCallbacks return false.
But what I have to inherit from (I want to add other property eg. isAffectByGravity or isColiidable ) .
Is it collidable or pose
Now I can make it not collide with other collidable by make this function
AllowContactGeneration
return false
And not affect by gravity by
make function in DemoCallbacks return false.
But what I have to inherit from (I want to add other property eg. isAffectByGravity or isColiidable ) .
Is it collidable or pose
Re: How can I make player detector not affect by gravity
Hi,
By default bepu 2 doesn't have collision groups, you need to implement them manually, the best place to do it is creating a custom INarrowPhaseCallbacks, that handle the collisions.
The DemoPoseIntegratorCallbacks, apply the gravity to all objects. So you need to create your custom IPoseIntegratorCallbacks that don't apply the gravity to selected objects. The easier way that don't modify the original library is adding a list at your custom PoseIntegrator.
By default bepu 2 doesn't have collision groups, you need to implement them manually, the best place to do it is creating a custom INarrowPhaseCallbacks, that handle the collisions.
The DemoPoseIntegratorCallbacks, apply the gravity to all objects. So you need to create your custom IPoseIntegratorCallbacks that don't apply the gravity to selected objects. The easier way that don't modify the original library is adding a list at your custom PoseIntegrator.
Re: How can I make player detector not affect by gravity
For an example of what Darkon described, check out the SubgroupFilteredCallbacks in the RagdollDemo. The brief explanation is that the custom data used for the callbacks is outside the engine in whatever format you find convenient. (In the demo, it's stored in a BodyProperty<T>, which is just a simple per-handle array of data.)
Generally, there's not much point to modifying the in-engine body data, and attempting to stick more data into those data structures can actually have some negative side effects. The in-engine Bodies arrays are packed according to in-engine access patterns, so sticking more data into them risks cache line inefficiency and higher bandwidth requirements.
Generally, there's not much point to modifying the in-engine body data, and attempting to stick more data into those data structures can actually have some negative side effects. The in-engine Bodies arrays are packed according to in-engine access patterns, so sticking more data into them risks cache line inefficiency and higher bandwidth requirements.
-
- Posts: 92
- Joined: Fri May 31, 2019 6:30 am
Re: How can I make player detector not affect by gravity
Thank you very much for both answer. I will look into SubgroupFilteredCallbacks. I will ask again if I don't understand anything.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Very Happy :D](./images/smilies/icon_biggrin.gif)
-
- Posts: 92
- Joined: Fri May 31, 2019 6:30 am
Re: How can I make player detector not affect by gravity
I have question about make player detector. Is broad phase narrow enough for make player detection( If i make player dector 16 metre radius sphere is it will be narrow like 60 - 70 metre). Or it is too broad some time(Or it range can be anything).
I have another question.
Can should I use Compound buider with character and playerdetection. Or I should add it separately. If it should add separately how do I munipulate it? make is same mass and velocity?
Thank you. You are very nice.
I have another question.
Can should I use Compound buider with character and playerdetection. Or I should add it separately. If it should add separately how do I munipulate it? make is same mass and velocity?
Thank you. You are very nice.
Re: How can I make player detector not affect by gravity
If you mean broad phase queries using Simulation.BroadPhase.GetOverlaps, then it'll find any collidables in the broad phase whose bounding boxes overlap the input bounding box. It won't check at the level of narrow phase contact generation. So it won't be as tight as checking contacts with a collision shape, but it won't be any looser than the bounding boxes of the shapes involved.I have question about make player detector. Is broad phase narrow enough for make player detection( If i make player dector 16 metre radius sphere is it will be narrow like 60 - 70 metre). Or it is too broad some time(Or it range can be anything).
If you mean using the INarrowPhaseCallbacks.AllowContactGeneration to collect overlaps, that'll have equivalent tightness to the BroadPhase.GetOverlaps. It'll be called for any objects with overlapping bounding boxes.
If you mean using the INarrowPhaseCallbacks.ConfigureContactManifold to receive notification of contacts being generated (and then presumably returning false for detector-involving pairs so no constraint is created), it'll provide full detail information about the collision- if there exist any contacts in the reported manifold with nonnegative depth, then the collidables are touching.
You could use a compound and then prevent contacts with the detector child by using the child-aware callbacks, yes. You could also use a separate object too; you'd probably want such a separate detector to be kinematic and just set to the same velocity and position as the character each timestep. Since it won't actually be generating any constraints, it doesn't matter if it's actually connected to the character. You could just pick whichever one is easier for you.Can should I use Compound buider with character and playerdetection. Or I should add it separately. If it should add separately how do I munipulate it? make is same mass and velocity?
Another option for player detection are the BroadPhase.GetOverlaps queries I mentioned earlier. Often, player detection doesn't require super tight accuracy, nor does it require checking every single character every single frame. If that's the case, then periodically using BroadPhase.GetOverlaps will tend to be faster and simpler to use.
Thank you. You are very nice.
![Razz :P](./images/smilies/icon_razz.gif)
-
- Posts: 92
- Joined: Fri May 31, 2019 6:30 am
Re: How can I make player detector not affect by gravity
Thank you Norbo. You are always answer my question.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Very Happy :D](./images/smilies/icon_biggrin.gif)
-
- Posts: 92
- Joined: Fri May 31, 2019 6:30 am
Re: How can I make player detector not affect by gravity
I try to make BoundingBox by its construction. So I need character position. How can I get it from bodyhandle. Thanks.
-
- Posts: 92
- Joined: Fri May 31, 2019 6:30 am
Re: How can I make player detector not affect by gravity
Find position of object
var position = new BepuPhysics.BodyReference(bodyHandle, Simulation.Bodies).Pose.Position
var position = new BepuPhysics.BodyReference(bodyHandle, Simulation.Bodies).Pose.Position
-
- Posts: 92
- Joined: Fri May 31, 2019 6:30 am
Re: How can I make player detector not affect by gravity
I try to use BroadPhase.GetOverlaps
after call periodicAABB once it call loop body two time.
Do you have any idea?
and also i got this assert error
What does this assert do?
Handle i send to this function is 0,0,0,1 and 0.
I will try to replicate it in stand alone. Thank you.
I struck here many times.
Code: Select all
public void PeriodicAABB()
{
Console.WriteLine("PeriodicAABB");
var hitHandler = new HitHandler { character = this };
System.Numerics.Vector3 minBB = Position - (sizeBB / 2);
System.Numerics.Vector3 maxBB = Position + (sizeBB / 2);
var box = new BepuUtilities.BoundingBox(minBB, maxBB);
Bepu.Simulation.BroadPhase.GetOverlaps(box, ref hitHandler);
}
Do you have any idea?
and also i got this assert error
Code: Select all
public ref T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
//TODO: As of this writing, the codegen for this isn't perfect. It's marginally better than doing bounds checks on a regular array.
//Still not quite as fast as a raw Unsafe.Add on a properly typed ref, or a pure pointer index.
//Hopefully, coreclr's Span<T> will result in some improvement here.
//No guarantee, though- they used to have a similar issue earlier in development but swapped to using internal intrinsics.
//Specifically, they're using:
//return ref Unsafe.Add(ref _pointer.Value, index);
//where _pointer is a ByReference<T>, which we cannot use.
Debug.Assert(index >= 0 && index < length, "Index out of range.");
return ref Get(Memory, index);
}
}
Handle i send to this function is 0,0,0,1 and 0.
I will try to replicate it in stand alone. Thank you.
I struck here many times.
-
- Posts: 92
- Joined: Fri May 31, 2019 6:30 am
Re: How can I make player detector not affect by gravity
The body of the enumerator is called for every overlap found, so it sounds like it found two overlaps.I try to use BroadPhase.GetOverlaps ... after call periodicAABB once it call loop body two time.
That assert happens when a buffer is accessed out of range (while in debug mode). Same thing as attempting to access values out of range in an array, except handled with asserts.What does this assert do?
Here, it appears to be the earliest/most common visible failure caused by a race condition. The repro starts a thread and updates the physics simulation on it continuously, and the main thread then tries to make modifications to the simulation as it's running. That will cause all kinds of corruption.
-
- Posts: 92
- Joined: Fri May 31, 2019 6:30 am
Re: How can I make player detector not affect by gravity
thank you norbo. It works.
-
- Posts: 92
- Joined: Fri May 31, 2019 6:30 am
Re: How can I make player detector not affect by gravity
I have question if I have question no relevance to thread should I ask it here or I should make another thread.
I have question about speed. it seem speed is accelerate from 0;
How can I make it same speed?(I want to make it syn with unity. Not sure though Unity seem use same speed that I Tell)
Now I stop it by not call UpdateCharacterGoal.
Update it seem it is linear but I misunderstand
Update I look into it again i don't think speed is linear
I have question about speed. it seem speed is accelerate from 0;
How can I make it same speed?(I want to make it syn with unity. Not sure though Unity seem use same speed that I Tell)
Now I stop it by not call UpdateCharacterGoal.
Update it seem it is linear but I misunderstand
Update I look into it again i don't think speed is linear
Re: How can I make player detector not affect by gravity
For new topics, a new thread is usually a good idea. It makes searching easier.I have question if I have question no relevance to thread should I ask it here or I should make another thread.
I'm not completely sure what your core question is, so here's a little info dump: in general, speed is the magnitude of the velocity. Character controllers work by specifying a target velocity in terms of the movement basis. The CharacterInput class handles the creation of a movement basis based on a camera direction and whatnot, and then creates a target velocity based on the constructor-provided 'speed' parameter and the input-derived movement direction.I have question about speed. it seem speed is accelerate from 0;
How can I make it same speed?(I want to make it syn with unity. Not sure though Unity seem use same speed that I Tell)
The speed provided to the constructor is a 'base' speed- the maximum speed the character will run along a flat surface when not sprinting. The CharacterInput arbitrarily picks sprinting to be 1.75 times faster than the base speed, and maximum air speed to be 0.2 times the base speed.
The character does not instantly reach the maximum speed in general. Instead, it accelerates with the maximumHorizontalForce (provided to the character input) up to those speeds (and 0.2 times that force while in the air).
If the target velocity given to the character controller is zero, then the character will accelerate towards zero relative velocity with its support by applying the maximumHorizontalForce.
The rate of acceleration will be maximumHorizontalForce / characterMass.
To make it match in unity, you'll need to make sure all the relevant scales are the same- same shape sizes, same velocities, same positions, same gravity- and then make sure the time step simulated duration and time step call real time frequency are similar. There will inevitably be some drift due to different simulation architecture and runtime details, so server-provided corrections will still be needed to keep things in sync, but it'll stay reasonably close together during extrapolation over fractions of a second.