コード例 #1
0
        /// <summary>
        /// Create the actual collision body.
        /// </summary>
        /// <param name="shape">Collision shape.</param>
        /// <param name="mass">Body mass.</param>
        /// <param name="inertia">Body inertia.</param>
        /// <param name="friction">Body friction.</param>
        private void CreateBody(Core.Physics.CollisionShapes.ICollisionShape shape, float mass, float inertia, float friction)
        {
            // store params and create the body
            _mass          = mass;
            _intertia      = inertia;
            _body          = new Core.Physics.RigidBody(shape, mass, inertia);
            _body.Friction = friction;
            _shape         = shape;

            // set self as attached data (needed for collision events)
            _body.EcsComponent = this;
        }
コード例 #2
0
 /// <summary>
 /// Create the actual collision body.
 /// </summary>
 /// <param name="shape">Collision shape.</param>
 private void CreateBody(Core.Physics.CollisionShapes.ICollisionShape shape)
 {
     _shape = shape;
     _body  = new Core.Physics.KinematicBody(shape);
 }
コード例 #3
0
 /// <summary>
 /// Create the kinematic body from shape instance.
 /// </summary>
 /// <param name="shape">Shape to use.</param>
 public KinematicBody(Core.Physics.CollisionShapes.ICollisionShape shape)
 {
     CreateBody(shape);
 }
コード例 #4
0
 /// <summary>
 /// Create the actual collision body.
 /// </summary>
 /// <param name="shape">Collision shape.</param>
 private void CreateBody(Core.Physics.CollisionShapes.ICollisionShape shape)
 {
     _shape             = shape;
     _body              = new Core.Physics.KinematicBody(shape);
     _body.EcsComponent = this;
 }
コード例 #5
0
 /// <summary>
 /// Create the physical body from shape instance.
 /// </summary>
 /// <param name="shape">Physical shape to use.</param>
 /// <param name="mass">Body mass (0 for static).</param>
 /// <param name="inertia">Body inertia (0 for static).</param>
 /// <param name="friction">Body friction.</param>
 public RigidBody(Core.Physics.CollisionShapes.ICollisionShape shape, float mass = 0f, float inertia = 0f, float friction = 1f)
 {
     CreateBody(shape, mass, inertia, friction);
 }