Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

how to get a 2d sprite to move towards mouse click smothly?

$
0
0
how do i get this code to make it so that it stops moving on mouse position when clicked public Transform firePoint; public GameObject player; public float bulletForce = 20f; // Update is called once per frame void Update() { if (Input.GetButtonDown("Fire1")) { dash1(); } } void dash1() { Rigidbody2D rb = player.GetComponent(); rb.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse); } }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>