Replies: 2 comments
-
That is what i tried right now: protected override void FixedUpdate() {
base.FixedUpdate();
Rigidbody body = this.GetComponent<Rigidbody>();
RayCastResult result = new RayCastResult();
ObjectLayer objectLayer = default;
switch (body.MotionType) {
case MotionType.Static:
objectLayer = Layers.NonMoving;
break;
case MotionType.Kinematic:
objectLayer = Layers.Moving;
break;
case MotionType.Dynamic:
objectLayer = Layers.Moving;
break;
}
using BroadPhaseLayerFilterImpl broadPhaseLayerFilterImpl = new BroadPhaseLayerFilterImpl(objectLayer);
using ObjectLayerFilterImpl objectLayerFilterImpl = new ObjectLayerFilterImpl(objectLayer);
using BodyFilterImpl bodyFilterImpl = new BodyFilterImpl(1);
bool test = body.Simulation.PhysicsSystem.NarrowPhaseQuery.CastRay((Double3) this.Position, new Vector3(0, -4, 0), ref result, broadPhaseLayerFilterImpl, objectLayerFilterImpl, bodyFilterImpl);
if (test == false)
Logger.Error(test + " " + result.BodyID);
if (test) {
float force = 0;
body.BodyInterface.AddForce(body.BodyId, new Vector3(0, (body.Shape.MassProperties.Mass * -body.Simulation.Settings.Gravity.Y) + force, 0));
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
it make not allot of sences, but i hope you can help me a bit :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello is there any RayCast example how to use the new method?
i do not really get the layers things, and why it always tell me true
Beta Was this translation helpful? Give feedback.
All reactions