Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Pick Up object, than spawn it again

$
0
0
Hi, I need to make so I can pick up object(oil flask) and it will spawn again on the same spot in 60 seconds for example. I achieved this: var up = transform.TransformDirection(Vector3.forward); var hit : RaycastHit; Debug.DrawRay(transform.position, up * 10, Color.green); if(Physics.Raycast(transform.position, up, hit, 10)){ Debug.Log("Hit"); if(hit.collider.gameObject.name == "Oil"){ if(Input.GetButtonDown("E")) { Debug.Log("hit"); } } So after I press E button object should dissapear and oil should spawn again in 60 seconds. I can make oil dissapear thats no problem, but as you know, If I destroy that oil by destroy command, spawn script wont work. If I put oil and Oil spawn empty object on the same spot raycast will catch only the first object, not the other one so it will send information only to one object. btw i will have many oils in map so I cant just set variable in that script to count to spawn that oil. because it would spawn oil everywhere where is oil spawn.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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