Ejemplo n.º 1
0
        private void FixedUpdate()
        {
            #if UNITY_EDITOR
            if (MonoInputManager.instance == null)
            {
                BurstDebug.Log("Waiting for MonoInputManager");
                return;
            }
            #endif

            float2 input          = MonoInputManager.instance.smoothedMove;
            float3 targetVelocity = new float3(input.x, 0, input.y);

            // Calculate how fast we should be moving
            targetVelocity  = transform.TransformDirection(targetVelocity); //change from local space to world space
            targetVelocity *= speed;

            // Apply a force that attempts to reach our target velocity
            float3 velocity       = rb.velocity;
            float3 velocityChange = (targetVelocity - velocity);
            velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange);
            velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange);
            velocityChange.y = -gravity * rb.mass / 10; //Apply gravity

            if (MonoInputManager.instance.jump && IsGrounded)
            {
                velocityChange.y = 0;
                rb.velocity      = new Vector3(rb.velocity.x, 26, rb.velocity.z);
            }

            rb.AddForce(velocityChange, ForceMode.VelocityChange);
        }
        public void Execute([ReadOnly] ref OutOfBoundsStruct bounds, ref Translation trans)
        {
            if (trans.Value.y > bounds.maxY)
            {
                trans.Value = bounds.resetPos;
                BurstDebug.Log("Max bound limit exceeded on entity, resetting pos");
            }

            else if (trans.Value.y < bounds.minY)
            {
                trans.Value = bounds.resetPos;
                BurstDebug.Log("Min bound limit exceeded on entity, resetting pos");
            }
        }
Ejemplo n.º 3
0
        void Update()
        {
            #if UNITY_EDITOR
            if (MonoInputManager.instance == null)
            {
                BurstDebug.Log("Waiting for MonoInputManager");
                return;
            }
            #endif

            float rotLeftRight = MonoInputManager.instance.mouse.x * sense;
            transform.Rotate(0, rotLeftRight, 0);

            vertRot -= MonoInputManager.instance.mouse.y * sense;
            vertRot  = Mathf.Clamp(vertRot, -45, 45);                        //Clamps the camera so you can't turn into an owl and look all the way up and behind you
            cam.transform.localRotation   = Quaternion.Euler(vertRot, 0, 0);
            visor.transform.localRotation = Quaternion.Euler(vertRot, 0, 0); // Moves the visor
        }