// Start is called before the first frame update void Start() { sounds = GetComponentInChildren <ShurikenSound>(); if (sounds == null) { Debug.LogError("Error: ShurikenSound.cs is missing on the " + gameObject.name + " gameObject."); } // Get a reference to the player playerShurikenScript = GameObject.FindObjectOfType <ShurikenThrow>(); // Get a reference to the shuriken collider collider = GetComponent <Collider2D>(); // Mouse's position during shuriken initialization initMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); // Rigidbody2D rbody = GetComponent <Rigidbody2D>(); // Direction for Shuriken to move moveDirection = initMousePos - new Vector2(transform.position.x, transform.position.y); moveDirection.Normalize(); // Set initial velocity rbody.velocity = moveDirection * throwSpeed * Time.fixedDeltaTime; velocity = Vector2.one; //Line effect _line = GetComponent <LineRenderer>(); //Animation _anim = GetComponent <Animator>(); }
private void Start() { _health = GetComponent <PlayerHealth>(); _throw = GetComponent <ShurikenThrow>(); _advCol = GetComponent <AdvPlayerCollider>(); _playerController = GetComponent <PlayerController>(); _anim = GetComponent <Animator>(); _rb = GetComponent <Rigidbody2D>(); _renderer = GetComponent <SpriteRenderer>(); }
//private int currCount = 0; void Start() { shurikenThrow = GameObject.FindObjectOfType <ShurikenThrow>(); previousShurikenLeft = 0; shurikenLeft = shurikenThrow.GetAmmoLeft(); maxShurikenAllowed = shurikenThrow.MaxShuriken; DisableExtraShurikenUI(); UpdateShurikenDisplay(); }