Rigidbody isbullet (#3649)

This commit is contained in:
Layla
2025-12-22 21:35:49 +00:00
committed by GitHub
parent e0ce9ace1d
commit 7a3cccfcb4
3 changed files with 34 additions and 0 deletions

View File

@@ -125,4 +125,6 @@ native class IPhysicsBody as NativeEngine.IPhysicsBody
void SetTrigger( bool trigger );
void ResetProxy();
void SetBullet( bool bEnabled );
}

View File

@@ -296,6 +296,24 @@ sealed public partial class Rigidbody : Component, Component.ExecuteInEditor, IG
}
}
/// <summary>
/// Enable enhanced continuous collision detection (CCD) for this body.
/// When enabled, the body performs CCD against dynamic bodies
/// (but not against other bodies with enhanced CCD enabled).
/// This is useful for fast-moving objects like bullets or rockets
/// that need reliable collision detection.
/// </summary>
[Advanced, Property]
public bool EnhancedCcd
{
get;
set
{
if ( field == value ) return;
if ( _body.IsValid() ) _body.EnhancedCcd = value;
}
}
/// <summary>
/// Resets the inertia tensor and its rotation to the values automatically calculated from the attached colliders.
/// This removes any custom overrides set via <see cref="InertiaTensor"/> or <see cref="InertiaTensorRotation"/>.
@@ -391,6 +409,8 @@ sealed public partial class Rigidbody : Component, Component.ExecuteInEditor, IG
_body.Velocity = _lastVelocity;
_body.AngularVelocity = _lastAngularVelocity;
_body.EnhancedCcd = EnhancedCcd;
// Make sure we clear these so we don't reapply them again later
_lastVelocity = default;
_lastAngularVelocity = default;

View File

@@ -1233,4 +1233,16 @@ public sealed partial class PhysicsBody : IHandle
{
native.ResetProxy();
}
/// <summary>
/// Enable enhanced continuous collision detection (CCD) for this body.
/// When enabled, the body performs CCD against dynamic bodies
/// (but not against other bodies with enhanced CCD enabled).
/// This is useful for fast-moving objects like bullets or rockets
/// that need reliable collision detection.
/// </summary>
public bool EnhancedCcd
{
set => native.SetBullet( value );
}
}