Hey, I’m working in Unity and have run into a few problems concerning Collision and Instantiating.
What I am trying to achieve is as follows…
A game object (in the context of the game is an Energy Ball) will be carried around by the player. When the player drops off the Energy Ball at a drop off point, I want ANOTHER exact clone of the Energy ball to instantiate elsewhere in the game world… (This is so there will always be an Energy ball of the player to carry back).
So…
What I need is that the Energy ball (which is a prefab) will Instantiate an exact copy of itself when it COLLIDES with the drop off point.
So far I have made this code (which was copied from the Unity scripting manual)
This basically makes it so ANY collision with another object will instantiate the Energy Ball prefab ten times…
However I don’t want it to instantiate when it collides with ANY object, but rather ONLY the drop off point object (named ‘stink’ and in a tag called ‘test’).
I’ve racked my brains but all attempts thus far have failed… Due to an overall inexperience in both Unity and Java scripting… If anyone could help me out then I would greatly appreciate it ^^.
Hey thanks for the reply. After I made this thread I did a bit more looking around and came up with this
This actually works fine. And I managed to add a destroy bit to the script also. However I have a new question ^^.
I want the NEW Instantiated object to appear in a position which is relative to its parent object… As it stands with the CURRENT script, the new instantiated object appears in relevance to the WORLD axis and not its parent.
How can I make it so the coordinates of where the instantiation will take place, will be in correlation to the objects parent? (at the moment it appears at 2.0, 0, 0 of the world axis).
Hey thanks for the reply. After I made this thread I did a bit more looking around and came up with this
This actually works fine. And I managed to add a destroy bit to the script also. However I have a new question ^^.
I want the NEW Instantiated object to appear in a position which is relative to its parent object… As it stands with the CURRENT script, the new instantiated object appears in relevance to the WORLD axis and not its parent.
How can I make it so the coordinates of where the instantiation will take place, will be in correlation to the objects parent? (at the moment it appears at 2.0, 0, 0 of the world axis).
Hi podperson. Sorry but I don’t understand how to implement what you just said into my script. I’m a complete Java newbie and have only been at it for a few weeks.
If you wouldnt mind, could you show me how I can pput that into the script I presented.
Hey thanks a lot ^^… The new Energy ball object instantiates in the cords by the parent… however the new object isnt actually IN the parent :? … If I can get the newly instantiated objects in the parent then I’m done… thanks a lot by the way ^^