i made a game where u throw knives , i already made a throwing script , it works fine , but how can i add a knife with an ability to split into 3 knives when player touches anywhere (after throwing )? see code sample and image for reference
void Start()
{
rb = GetComponent<Rigidbody2D>();
//rb.rotation = 45f;
//AudioSource throwsound = gameObject.AddComponent<AudioSource>();
shu_throw = GetComponent<AudioSource>();
audioSource = GetComponent<AudioSource>();
RotShu.SetActive(false);
alphalevel = 1f;
//InvokeRepeating("spawntrail", 0.05f, 0.05f);
}
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);
the throwing is done , all i want is a script that allows detection of player touch so th eobject splits after throwing , just to make this clear and simple , seen that blue bird in angry birds ? when you shoot it u click on screen whenever you want and the birds splits into 3 ? thats what i want to make, i want just the click detection part i will take care of the rest , and thank you