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);
        }
Ejemplo n.º 2
0
 void OnEnable()
 {
     if (cam == null || visor == null)
     {
         BurstDebug.LogWarning("Cam or visor net set in MonoMouse on object " + name + ", disabling");
         enabled = false;
     }
 }
Ejemplo n.º 3
0
 private void Start()
 {
     if (rb == null)
     {
         BurstDebug.LogWarning("Rigidbody is not set on object " + name);
         enabled = false;
     }
 }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     if (mInterface == null)
     {
         BurstDebug.LogError("AHHHHHHHHHHHHHHH");
         gameObject.SetActive(false);
     }
 }
Ejemplo n.º 5
0
    private void OnEnable()
    {
        if (controls != null)
        {
            controls.Player.Enable();
        }

        else
        {
            BurstDebug.LogWarning("Object enabled without a PlayerControls reference, this could cause unintentional side effects");
        }
    }
        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.º 7
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
        }
Ejemplo n.º 8
0
    protected override void OnUpdate()
    {
        if (MonoInputManager.instance == null)
        {
            BurstDebug.LogWarning("Waiting for MonoInputManager");
            return;
        }

        MonoInputManager inputMan = MonoInputManager.instance;

        Entities.ForEach((ref InputStruct input) =>
        {
            input.moveRaw = inputMan.move;
            input.move    = inputMan.smoothedMove;

            input.mouseX = inputMan.mouse.x;
            input.mouseY = inputMan.mouse.y;
            input.alt    = inputMan.alt;

            //input.shift = Input.GetKey(KeyCode.LeftShift);
            input.jump = inputMan.jump;
        });
    }