Пример #1
0
        private void DetectInteractable()
        {
            bool       can_interact = false;
            var        scene        = Universe.GetScene <PhysicsScene>();
            Vec3       origin       = m_CameraEntity.Position;
            Vec3       dir          = -m_CameraEntity.Direction;
            RaycastHit hit          = new RaycastHit();

            scene.RaycastEx(origin, dir, 1.5f, ref hit, entity);

            if (hit.EntityID != -1)
            {
                Entity   e        = Universe.GetEntity(hit.EntityID);
                Holdable holdable = e.GetComponent <Holdable>();
                if (holdable != null)
                {
                    can_interact = true;
                    if (m_IsKeyPressed.ContainsKey('e'))
                    {
                        Hold(e);
                    }
                }
            }
            m_HoldNoticeUI.GetComponent <GuiRect>().IsEnabled = can_interact;
        }
Пример #2
0
        private void Shoot()
        {
            var        scene  = Universe.GetScene <PhysicsScene>();
            Vec3       origin = m_CameraEntity.Position;
            Vec3       dir    = -m_CameraEntity.Direction;
            RaycastHit hit    = new RaycastHit();

            scene.RaycastEx(origin, dir, 100, ref hit, entity);

            if (hit.EntityID != -1)
            {
                Universe.InstantiatePrefab(m_HitParticlePrefab, hit.Position, new Quat(0, 0, 0, 1), 1);
            }
        }