// Use this for initialization
 void Start()
 {
     characterRb      = GetComponent <Rigidbody>();
     boatRb           = boat.GetComponent <Rigidbody>();
     spearRb          = spear.GetComponent <Rigidbody>();
     ss               = spear.GetComponent <SpearScript>();
     cs               = mainCamera.GetComponent <CameraScript>();
     playerRestrainer = boat.GetComponent <FixedJoint>();
 }
Example #2
0
    void Start()
    {
        SS = GameObject.FindObjectOfType <SpearScript>();
        Ps = GameObject.FindObjectOfType <PlayerScript>();

        rb = GetComponent <Rigidbody2D>();

        if (target != null)
        {
            targetDirection = (target.position - transform.position).normalized * speed;
        }
        rb.velocity = new Vector2(targetDirection.x, targetDirection.y);
    }
Example #3
0
    void Start()
    {
        SS = GameObject.FindObjectOfType <SpearScript>();
        SoundManagerScript.PlaySound(SoundManagerScript.spear);
        Vector3 mousePosition = Input.mousePosition;

        mousePosition = Camera.main.ScreenToWorldPoint(mousePosition);

        Vector2 direction = new Vector2(mousePosition.x - transform.position.x, mousePosition.y - transform.position.y);

        transform.up = direction;

        Ps = GameObject.FindObjectOfType <PlayerScript>();
    }
    void throwSpear()
    {
        Ray     mouseRay      = Camera.main.ScreenPointToRay(Input.mousePosition);
        Vector3 mousePosition = mouseRay.origin + (mouseRay.direction * -Camera.main.transform.position.z);
        float   angle         = Vector3.Angle(transform.right, new Vector3(mousePosition.x - transform.position.x, mousePosition.y - transform.position.y, 0));//Vector3.Angle(transform.position, mousePosition);

        if (mousePosition.y < 0)
        {
            angle = -angle;
        }
        GameObject g = Instantiate(spear, fishSeat.position, Quaternion.AngleAxis(angle, Vector3.forward));

        spearRb  = g.GetComponent <Rigidbody>();
        ss       = g.GetComponent <SpearScript>();
        ss.owner = transform;
        SetCameraTarget(g.transform);
        currentSpear = g;
    }
Example #5
0
    void Start()
    {
        if (isHome == false)
        {
            SS     = GameObject.FindObjectOfType <SpearScript>();
            SShoot = GameObject.FindObjectOfType <ScriptShooter>();

            if (SShoot == null)
            {
                GameObject.FindGameObjectWithTag("ShooterBar").SetActive(false);
            }

            if (SS == null)
            {
                GameObject.FindGameObjectWithTag("SpearBar").SetActive(false);
            }
        }
    }