- Home /
Projectile Terrain Destruction
Hello Everyone,
I am baffled with this little issue I have, and this time I have made sure it's not some careless error.
I have a script that dynamically destroys terrain but only where the mouse cursor is. I have a vehicle that shoots rockets, and I want the rockets to destroy the terrain, not clicking the mouse. How do I store the position of my projectile?
I've included the relevant of code:
function OnCollisionEnter (hit:Collision)
{
if (hit.gameObject.tag=="projectile")
{
var x : int = Mathf.Lerp(0, xRes, Mathf.InverseLerp(0, tData.size.x, mouse.mousepos.x));
var z : int = Mathf.Lerp(0, yRes, Mathf.InverseLerp(0, tData.size.z, mouse.mousepos.z));
I appreciate your help.
Answer by Hyperion · Aug 03, 2013 at 09:02 PM
Wow, ok, I fixed it. And it wasn't too bad. I just put "GameObject.FindWithTag("projectile").transform.position" where it said mouse.mousepos.
I hope this helps anyone else working with Dynamic Terrain. You can ask me for more detail. You can also get the full script from the video at the link: