示例#1
0
 public void Execute([ReadOnly] ref Unity.Transforms.Position pos,
                     [ReadOnly] ref Unity.Transforms.Rotation rot,
                     ref SphereCollider sphere_collider)
 {
     sphere_collider.position_ = math.mul(rot.Value, sphere_collider.offset_position_) + pos.Value;
     sphere_collider.updated_  = 1; // true
 }
        //-----------------------------------------------------------------------------
        public void Execute(int index)
        {
            var pos   = Positions[index].Value;
            var rot   = Rotations[index].Value;
            var vel   = Velocity[index].Value;
            var speed = math.length(vel);

            pos += vel * TimeDelta;

            var gridIndex     = GridUtilties.WorldToIndex(GridSettings, pos);
            var terrainHeight = (gridIndex < 0 ? pos.y : Heights[gridIndex]);
            var currUp        = math.up(rot);
            var normal        = gridIndex < 0 ? currUp : Normals[gridIndex];

            var targetHeight = terrainHeight + 5;

            pos.y = pos.y + (targetHeight - pos.y) * math.min(TimeDelta * (speed + 1), 1);

            // clamp position
            float minWorldX = -GridSettings.worldSize.x * .5f;
            float maxWorldX = -minWorldX;
            float minWorldZ = -GridSettings.worldSize.y * .5f;
            float maxWorldZ = -minWorldZ;

            if (pos.x < minWorldX)
            {
                pos.x = minWorldX + 1;
            }
            if (pos.x > maxWorldX)
            {
                pos.x = maxWorldX - 1;
            }
            if (pos.z < minWorldZ)
            {
                pos.z = minWorldZ + 1;
            }
            if (pos.z > maxWorldZ)
            {
                pos.z = maxWorldZ - 1;
            }

            var currDir    = math.forward(rot);
            var normalDiff = normal - currUp;
            var newUp      = math.normalize(currUp + normalDiff * math.min(TimeDelta * 10, 1));
            var newDir     = currDir;

            if (speed > .1f)
            {
                var speedPer   = (speed / SteerParams.MaxSpeed) * 1.75f;
                var desiredDir = math.normalize(vel);
                var dirDiff    = desiredDir - currDir;
                newDir = math.normalize(currDir + dirDiff * math.min(TimeDelta * SteerParams.RotationSpeed * speedPer, 1));
            }
            rot = quaternion.lookRotation(newDir, newUp);
            Positions[index] = new Position(pos);
            Rotations[index] = new Rotation(rot);
        }
示例#3
0
            public void Execute(int index)
            {
                Entity colliderEntity = ColliderEntity[index];

                Unity.Transforms.Position cp = PositionFromEntity[colliderEntity];
                cp.Value = PositionFromEntity[Collider[index].RigidBodyEntity].Value;
                PositionFromEntity[colliderEntity] = cp;

                Unity.Transforms.Rotation cr = RotationFromEntity[colliderEntity];
                cr.Value = RotationFromEntity[Collider[index].RigidBodyEntity].Value;
                RotationFromEntity[colliderEntity] = cr;
            }
示例#4
0
            public void Execute(int index)
            {
                Entity transformEntity         = Entities[index];
                Entity followedRigidBodyEntity = FollowRigidbody[index].RigidBodyEntity;

                Unity.Transforms.Position p = PositionFromEntity[transformEntity];
                p.Value = PositionFromEntity[followedRigidBodyEntity].Value;
                PositionFromEntity[transformEntity] = p;

                Unity.Transforms.Rotation r = RotationFromEntity[transformEntity];
                r.Value = RotationFromEntity[followedRigidBodyEntity].Value;
                RotationFromEntity[transformEntity] = r;
            }
 public void Execute(int index)
 {
     OutputPositions[index] = new Position {
         Value = Positions[index].Value
     };
     OutputRotations[index] = new Rotation {
         Value = Rotations[index].Value
     };
     OutputVelocities[index] = new Velocity {
         Value = Velocities[index].Value
     };
     OutputTargetReached[index] = new TargetReached {
         Value = TargetReached[index].Value, CurrentGoal = TargetReached[index].CurrentGoal
     };
 }