Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

How can I display Cloned ball velocity in text ?

$
0
0
My cannon is shooting balls whenever FireCannon() function is called by creating a clone of cannonBall. I want to find the velocity of every cloned ball which is being fired & display it as text. I have tried to write a code which is displaying the velocity of the last cannonBall(cloned) fired but I am pretty sure this is not the right velocity. Can anyone help !! I am a beginner. public void FireCannon() { GameObject cannonBallCopy = Instantiate(cannonBall, shotPos.position, transform.rotation) as GameObject; cannonballRB = cannonBallCopy.GetComponent(); cannonballRB.AddForce(transform.forward * BlastPower); Instantiate(shotPos, shotPos.position, shotPos.rotation); speed = Mathf.RoundToInt(Vector3.Distance(shotPos.position, shotPos.localScale) / Time.fixedDeltaTime); gameText.text = "Speed of ball: " + speed + "m/s"; }

Viewing all articles
Browse latest Browse all 508


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