Ejemplo n.º 1
0
    protected override void fireatPlayer()
    {
        distToPlayer = Vector3.Distance(player.gameObject.transform.position, this.transform.position);

        Debug.DrawLine(Torreta.transform.position, player.gameObject.transform.position);

        if (distToPlayer <= NoticeRange)
        {
            lookpos   = player.gameObject.transform.position - this.transform.position;
            lookpos.y = 0;
            lookRot   = Quaternion.LookRotation(lookpos);
            Torreta.transform.localRotation = Quaternion.Slerp(Torreta.transform.localRotation, lookRot, Time.deltaTime * 1.5f);
            float point = Vector3.Dot(lookpos.normalized, Torreta.transform.forward.normalized);
            if (Mathf.Abs(point) >= 0.90f)
            {
                Fs.FireP(firePos.transform.position, Torreta.transform.localRotation, player.gameObject);
            }
        }
    }
Ejemplo n.º 2
0
    private void Inputs()
    {
        if (!canMove)
        {
            return;
        }
        float mousex = Input.GetAxis("Mouse X") * MouseSensibility * Time.deltaTime;

        this.transform.Rotate(Vector3.up * mousex);
        if (Input.GetKey(KeyCode.W))
        {
            rb.AddForce(transform.forward.normalized * CurrentSpeed);
        }
        else if (Input.GetKey(KeyCode.S))
        {
            rb.AddForce(-transform.forward.normalized * (CurrentSpeed * BackMulti));
        }
        if (Input.GetKey(KeyCode.A))
        {
            mesh.transform.localRotation = Quaternion.Slerp(mesh.transform.localRotation, Quaternion.Euler(new Vector3(-80, -90, 90)), inclSpeed * Time.time);
            rb.AddForce(-transform.right.normalized * CurrentSpeed);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            mesh.transform.localRotation = Quaternion.Slerp(mesh.transform.localRotation, Quaternion.Euler(new Vector3(-100, -90, 90)), inclSpeed * Time.time);


            rb.AddForce(transform.right.normalized * CurrentSpeed);
        }
        else
        {
            mesh.transform.localRotation = Quaternion.Slerp(mesh.transform.localRotation, Quaternion.Euler(new Vector3(-90, 0, 0)), inclSpeed * Time.time);
        }
        if (Input.GetKey(KeyCode.Space))
        {
            Vector3 f = transform.forward * 1.5f;
            f.y = 0;
            Fs.FireP(transform.position + f, transform.rotation, null);
        }
    }
Ejemplo n.º 3
0
 public void fireTorre(GameObject planet)
 {
     Fs.FireP(firePos.transform.position, Torreta.transform.rotation, player.gameObject);
 }