コード例 #1
0
        private bool IsPositionValid(Vector3 pos)
        {
            Vector3 center = pos + Vector3.up * 0.5f;
            Vector3 ground_pos;

            return(PhysicsTool.FindGroundPosition(center, 1f, valid_floor, out ground_pos));
        }
コード例 #2
0
        //Find landing position to make sure it wont land on an obstacle
        private bool FindGroundPosition(Vector3 pos, float radius, out Vector3 ground_pos)
        {
            Vector3 offest = new Vector3(Random.Range(-radius, radius), 0f, Random.Range(radius, radius));
            Vector3 center = pos + offest;
            bool    found  = PhysicsTool.FindGroundPosition(center, 50f, character.ground_layer.value, out ground_pos);

            return(found);
        }
コード例 #3
0
        private float FindYPosition(Vector3 pos)
        {
            Vector3 center = pos + Vector3.up * 10f;
            Vector3 ground_pos;
            bool    found = PhysicsTool.FindGroundPosition(center, 20f, valid_floor, out ground_pos);

            return(found ? ground_pos.y : pos.y);
        }
コード例 #4
0
        public void Spawn()
        {
            CraftData data = spawn_data[Random.Range(0, spawn_data.Length)];

            if (data != null)
            {
                float   radius = Random.Range(0f, spawn_radius);
                float   angle  = Random.Range(0f, 360f) * Mathf.Deg2Rad;
                Vector3 offset = new Vector3(Mathf.Cos(angle), 0f, Mathf.Sin(angle)) * radius;
                Vector3 pos    = transform.position + offset;
                Vector3 ground_pos;
                bool    found = PhysicsTool.FindGroundPosition(pos, 100f, valid_floor_layer.value, out ground_pos);
                if (found)
                {
                    CraftData.Create(data, ground_pos);
                }
            }
        }