Doing 2D game side scroll, the character able to pick up stuff and throw it on the enemy by using the mouse left click with pointing on the enemy, i need to draw an arrow following the mouse position ?
private Vector3 screenPoint;
private Vector3 offset;
private float throwSpeed = 6f;
public void ThrowPickup()
{
if(throwSound)
{
audio.volume = 1;
audio.clip = throwSound;
audio.Play ();
}
Destroy (joint);
heldObj.rigidbody.interpolation = objectDefInterpolation;
heldObj.rigidbody.mass /= weightChange;
screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);
offset = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z)) - gameObject.transform.position;
float XInc = offset.x * throwSpeed;
float YInc = offset.y * throwSpeed;
heldObj.rigidbody.velocity += new Vector3(XInc, YInc, 0);
heldObj = null;
timeOfThrow = Time.time;
}