I am trying to implement a simple throw-stone script and everything works fine But the position of the instantiated projectile. I am using mixamo animation events for this - and I am instantiating a projectile after 2 seconds (wher, in animation, the hand is in the last position to hold the stone). Here’s what I came up with so far
using UnityEngine;
using System.Collections;
public class InstantiateStone : MonoBehaviour
{
public Rigidbody stonePrefab;
void Start()
{
StartCoroutine(waitSeconds(2.0f));
}
IEnumerator waitSeconds(float seconds)
{
yield return new WaitForSeconds(seconds);
Rigidbody MyProjectile;
MyProjectile = Instantiate(stonePrefab, transform.position, transform.rotation) as Rigidbody;
MyProjectile.rigidbody.AddForce(new Vector3(-2000,0,0));
}
}
I am not sure how to approach this, help is much appreciated!