its a game about throwing knives , so the player throws knives , what i want is the player being able to make the knife disappear when player clicks anywhere ? heres a code sample to show you where to put the code in (ps : i already written a code about throwing function and it works fine )
void Start()
{
rb = GetComponent<Rigidbody2D>();
RotShu.SetActive(false);
alphalevel = 1f;
}
void Update()
{
if (IsPressed)
{
Vector2 mousepos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (Vector3.Distance(mousepos, hook.position) > maxdragdis)
{
rb.position = hook.position + (mousepos - hook.position).normalized * maxdragdis;
}
else
rb.position = mousepos;
}
}
void OnMouseDown()
{
IsPressed = true;
rb.isKinematic = true;
}
void OnMouseUp()
{
IsPressed = false;
rb.isKinematic = false;
StartCoroutine(Release());
shu_throw.Play();
RotShu.SetActive(true);
GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 0);
}