Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
Rod

Help with a simple script.

Question

Could someone help me with a simple script.

Where when it collides with an object it activates an other object?

It would be really apreciated :)

I tried writing it but got a bunch of errors, with the trigger collisions and semicolones.

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

This should be in the help section. But anyways, what are you looking for exactly in activating an object? ex: on collision play animation/sound, on collision activate mesh, on collision instantiate object. Let me know and I'll write something up for you

Share this post


Link to post
Share on other sites

  • 0

Yeah instantiate Object or script it would realy be the same.

Tried to wright it my self. but no luck :(

Something like this

Please login or register to see this code.

Or something like this goes that way. What I wanted to do that at colission with the player on a level its instantiate a gameobject or script the AI spawners.

Share this post


Link to post
Share on other sites
  • 0

Ok gotcha. Actually, in all, the set up of your script is great. The only thing that's wrong is the minor stuff. So instead of just writing a new one I'll just tell you how to do it. The var Collider = Gameobject part needs to be var Collider : GameObject; in variables each word needs to be capitolized ending with a semicolon. All functions need to be lowercase. The reason for that is because it's just saying it is a function and what function is called is capitolized to distinguish which function it is, like this: function Update(){ but remember that unity has it's own prespecified functions included: Update, Start, OnMouseOver, OnCollisionEnter, etc. so OnCollisionEnter doesn't need to be in your update function. And last but not least, when instantiating an object you need the properties at which it's going to appear. So instead of gameobject = instantiate, it's actually var BigAssFireBall = Instantiate(the object your instantiating which in your case is Collider, the position it's instantiating which if it's on itself it's transform.position, the rotation its going to instantiate at which is normally Quaternion.identity); besides that your good man. Just remember those fundamentals. As a guide, go to the scripts section on this forum and click on the bouncing betty and bouncing freddy script I posted and instead of OnCollisionExit put OnCollisionEnter and change how you want it. Happy scripting

Share this post


Link to post
Share on other sites
  • 0

:d Finally got a script working.

Please login or register to see this code.

So what I used it was for, when my player collide with an invisible box it istantiate a prefab or a object with a rigidbody and a collider. remember to add Player Tag o change tag.

Gonna but it in scripts sections! Thx Man!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...