Inheritance: MonoBehaviour
Example #1
0
 // Use this for initialization
 private void Awake()
 {
     cController = GetComponent <CameraController>();
     firstP      = GetComponent <FirstPerson>();
     thirdP      = GetComponent <FirstPersonCamera>();
     cam         = GetComponent <Camera>();
 }
Example #2
0
    // Use this for initialization
    void Start()
    {
        player = GameObject.Find("Controller");

        playerScript = player.GetComponent<FirstPerson>();

        setAlpha(0);
    }
 void OnTriggerExit( Collider c )
 {
     if ( player != null && c.collider == player.collider ) {
         player.isSwimming = false;
         player = null;
         pullMove = null;
     }
 }
 // public float minSpeedToSplashSound = 5f;
 void OnTriggerEnter(Collider c)
 {
     if ( c.GetComponent<FirstPerson>() ) {
         player = c.GetComponent<FirstPerson>();
         pullMove = player.GetComponent<PullMove>();
         player.isSwimming = true;
     }
 }
Example #5
0
        public static FirstPerson FromGltf(this VrmProtobuf.FirstPerson fp, List <Node> nodes)
        {
            var self = new FirstPerson();

            // self.m_offset = fp.FirstPersonBoneOffset.ToVector3();
            self.Annotations.AddRange(fp.MeshAnnotations
                                      .Select(x => new FirstPersonMeshAnnotation(nodes[x.Node.Value], x.FirstPersonType.FromGltf())));
            return(self);
        }
Example #6
0
        public static FirstPerson FromGltf(this UniGLTF.Extensions.VRMC_vrm.FirstPerson fp, List <Node> nodes)
        {
            var self = new FirstPerson();

            if (fp.MeshAnnotations != null)
            {
                self.Annotations.AddRange(fp.MeshAnnotations
                                          .Select(x => new FirstPersonMeshAnnotation(nodes[x.Node.Value], x.FirstPersonType.FromGltf())));
            }
            return(self);
        }
    public void MoveCamera(Transform target)
    {
        if (firstPerson == null)
        {
            firstPerson = FindObjectOfType <FirstPerson>();
        }

        CameraPosition = target.position;
        CameraRotation = target.rotation.eulerAngles;

        firstPerson.MoveCamera(target);
    }
Example #8
0
 IEnumerator WarpTimer( FirstPerson player )
 {
     player.canMove = false;
     ScreenFade.Fade( Color.white, 1f, 0f, 0.5f, 0f, true );
     player.rigidbody.velocity = Vector3.zero;
     player.rigidbody.useGravity = false;
     player.transform.position = warpTunnel.position;
     yield return new WaitForSeconds( 3f );
     ScreenFade.Fade( Color.black, 0f, 1f, 0.5f, 0f, true );
     yield return new WaitForSeconds( 0.5f );
     Application.LoadLevel( 2 );
 }
Example #9
0
        public static (LookAt, FirstPerson) Migrate(glTF gltf, JsonNode vrm0)
        {
            // VRM1
            // firstPerson に同居していた LookAt は独立します
            LookAt lookAt = default;

            lookAt = new LookAt
            {
                RangeMapHorizontalInner = MigrateLookAtRangeMap(vrm0["lookAtHorizontalInner"]),
                RangeMapHorizontalOuter = MigrateLookAtRangeMap(vrm0["lookAtHorizontalOuter"]),
                RangeMapVerticalDown    = MigrateLookAtRangeMap(vrm0["lookAtVerticalDown"]),
                RangeMapVerticalUp      = MigrateLookAtRangeMap(vrm0["lookAtVerticalUp"]),
                Type = MigrateLookAtType(vrm0["lookAtTypeName"]),
                OffsetFromHeadBone = MigrateVector3.Migrate(vrm0, "firstPersonBoneOffset"),
            };

            var firstPerson = new FirstPerson
            {
                // VRM1
                // firstPersonBoneOffset は廃止されます。LookAt.OffsetFromHeadBone を使ってください。
                // firstPersonBone は廃止されます。Head 固定です。
                MeshAnnotations = new System.Collections.Generic.List <MeshAnnotation>(),
            };

            if (vrm0.TryGet("meshAnnotations", out JsonNode meshAnnotations))
            {
                Func <int, int> meshIndexToRenderNodeIndex = meshIndex =>
                {
                    for (int i = 0; i < gltf.nodes.Count; ++i)
                    {
                        var node = gltf.nodes[i];
                        if (node.mesh == meshIndex)
                        {
                            return(i);
                        }
                    }
                    throw new NotImplementedException("mesh is not used");
                };
                foreach (var x in meshAnnotations.ArrayItems())
                {
                    var a = new MeshAnnotation
                    {
                        Node = meshIndexToRenderNodeIndex(x["mesh"].GetInt32()),
                        Type = MigrateFirstPersonType(x["firstPersonFlag"]),
                    };
                    firstPerson.MeshAnnotations.Add(a);
                }
            }
            ;

            return(lookAt, firstPerson);
        }
        public static FirstPerson FromGltf(this VrmFirstPerson fp, List <Node> nodes, List <MeshGroup> meshes)
        {
            var self = new FirstPerson();

            self.Annotations.AddRange(fp.meshAnnotations
                                      .Select(x =>
            {
                var meshGroup = meshes[x.mesh];
                var node      = nodes.First(y => y.MeshGroup == meshGroup);
                return(new FirstPersonMeshAnnotation(node, (FirstPersonMeshType)x.firstPersonFlag));
            }));
            return(self);
        }
Example #11
0
 IEnumerator WarpTimer(FirstPerson player )
 {
     player.canMove = false;
     ScreenFade.Fade (Color.cyan, 1f, 0f, 1f, 0f, true);
     player.rigidbody.velocity = Vector3.zero;
     player.rigidbody.useGravity = false;
     player.transform.position = warpTunnel.position;
     yield return new WaitForSeconds( 2f);
     ScreenFade.Fade (Color.blue, 1f, 0f, 1f, 0f, true);
     yield return new WaitForSeconds( 1f);
     player.canMove = true;
     player.rigidbody.useGravity = true;
     player.transform.position = destination.position;
 }
Example #12
0
 IEnumerator WarpTimer(FirstPerson player )
 {
     player.canMove = false;
     ScreenFade.Fade (Color.magenta, 1f, 0f, 0.5f, 0f, true);
     player.rigidbody.velocity = Vector3.zero;
     player.rigidbody.useGravity = false;
     player.transform.position = warpTunnel.position;
     yield return new WaitForSeconds( 2.5f);
     ScreenFade.Fade (Color.red, 1f, 0f, 1f, 0f, true);
     yield return new WaitForSeconds( 0.5f);
     player.canMove = true;
     player.rigidbody.useGravity = true;
     player.transform.position = teleportDestination.position;
     player.transform.rotation = teleportDestination.rotation;
 }
 // Use this for initialization
 void Start()
 {
     isDashing        = false;
     cam              = GetComponentInChildren <Camera>();
     control          = GetComponent <CharacterController>();
     camAngle         = 0;
     Cursor.lockState = CursorLockMode.Locked;
     yVel             = 0;
     jumpSpeed        = JumpDist / JumpTime - Gravity / (2 * JumpTime);
     canJump          = 0;
     PLAYER           = this;
     Cursor.visible   = false;
     GUN_AQUIRED      = false;
     if (gunMesh != null)
     {
         gunMesh.SetActive(false);
     }
 }
Example #14
0
        public static VrmProtobuf.FirstPerson ToGltf(this FirstPerson self, List <Node> nodes, List <MeshGroup> meshes)
        {
            if (self == null)
            {
                return(null);
            }

            var firstPerson = new VrmProtobuf.FirstPerson
            {
            };

            foreach (var x in self.Annotations)
            {
                firstPerson.MeshAnnotations.Add(new VrmProtobuf.FirstPerson.Types.MeshAnnotation
                {
                    Mesh            = meshes.IndexOfThrow(x.Mesh),
                    FirstPersonType = (VrmProtobuf.FirstPerson.Types.MeshAnnotation.Types.FirstPersonType)x.FirstPersonFlag,
                });
            }
            return(firstPerson);
        }
Example #15
0
        public static VrmProtobuf.FirstPerson ToGltf(this FirstPerson self, List <Node> nodes)
        {
            if (self == null)
            {
                return(null);
            }

            var firstPerson = new VrmProtobuf.FirstPerson
            {
            };

            foreach (var x in self.Annotations)
            {
                firstPerson.MeshAnnotations.Add(new VrmProtobuf.MeshAnnotation
                {
                    Node            = nodes.IndexOfThrow(x.Node),
                    FirstPersonType = EnumUtil.Cast <VrmProtobuf.MeshAnnotation.Types.FirstPersonType>(x.FirstPersonFlag),
                });
            }
            return(firstPerson);
        }
Example #16
0
        public static UniGLTF.Extensions.VRMC_vrm.FirstPerson ToGltf(this FirstPerson self, List <Node> nodes)
        {
            if (self == null)
            {
                return(null);
            }

            var firstPerson = new UniGLTF.Extensions.VRMC_vrm.FirstPerson
            {
            };

            foreach (var x in self.Annotations)
            {
                firstPerson.MeshAnnotations.Add(new UniGLTF.Extensions.VRMC_vrm.MeshAnnotation
                {
                    Node            = nodes.IndexOfThrow(x.Node),
                    FirstPersonType = EnumUtil.Cast <UniGLTF.Extensions.VRMC_vrm.FirstPersonType>(x.FirstPersonFlag),
                });
            }
            return(firstPerson);
        }
Example #17
0
 // Use this for initialization
 void Start()
 {
     time = Time.time;
     fPerson = GetComponent<FirstPerson>();
 }
Example #18
0
 public void ExportVrmFirstPersonAndLookAt(FirstPerson firstPerson, LookAt lookat, List <MeshGroup> meshes, List <Node> nodes)
 {
     Storage.gltfVrm.FirstPerson = firstPerson.ToGltf(nodes);
     Storage.gltfVrm.LookAt      = lookat.ToGltf();
 }
Example #19
0
        /// <summary>
        /// Add first person camera controller.
        /// </summary>
        /// <param name="window">window that receives input system events</param>
        /// <param name="firstPerson">The first person transform.</param>
        public static FirstPersonMovementState AddFirstPersonCameraEvents(this INativeWindow window, FirstPerson firstPerson)
        {
            window.MouseMove += (s, e) =>
            {
                if (ButtonState.Pressed == e.Mouse.LeftButton)
                {
                    firstPerson.Heading += 300 * e.XDelta / (float)window.Width;
                    firstPerson.Tilt    += 300 * e.YDelta / (float)window.Height;
                }
            };
            var state = new FirstPersonMovementState();

            window.KeyDown += (s, e) =>
            {
                var movement = state.movement;
                var delta    = 1f;
                switch (e.Key)
                {
                case Key.A: movement.X = -delta; break;

                case Key.D: movement.X = delta; break;

                case Key.Q: movement.Y = -delta; break;

                case Key.E: movement.Y = delta; break;

                case Key.W: movement.Z = -delta; break;

                case Key.S: movement.Z = delta; break;
                }
                state.movement = movement;
            };
            window.KeyUp += (s, e) =>
            {
                var movement = state.movement;
                switch (e.Key)
                {
                case Key.A: movement.X = 0f; break;

                case Key.D: movement.X = 0f; break;

                case Key.Q: movement.Y = 0f; break;

                case Key.E: movement.Y = 0f; break;

                case Key.W: movement.Z = 0f; break;

                case Key.S: movement.Z = 0f; break;
                }
                state.movement = movement;
            };
            return(state);
        }
Example #20
0
 public void ExportVrmFirstPersonAndLookAt(FirstPerson firstPerson, LookAt lookat, List <MeshGroup> meshes, List <Node> nodes)
 {
     Gltf.Extensions.VRMCVrm.FirstPerson = firstPerson.ToGltf(nodes, meshes);
     Gltf.Extensions.VRMCVrm.LookAt      = lookat.ToGltf();
 }
Example #21
0
 void Start()
 {
     p_character = GetComponent <CharacterController>();
     p_Camera    = Camera.main;
     singleton   = this;
 }