Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Steve Cogbill · Jan 23, 2014 at 05:16 PM · triggerspawnprojectile

Spawning a projectile with a trigger

Im trying to make a projectile spawn from a turret when an "enemy" tagged object enters its collider or trigger zone. I have 2 empty game objects positioned where I would like the projectiles to spawn from and I also have the projectile ready to go as a prefab. I've been trying to come up with a script myself but I can't seem to get it to work so far. Any help with this code would be greatly appreciated! Steve

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Steve Cogbill · Feb 02, 2014 at 04:16 AM 0
Share

I still haven't made any progress. If anyone could help, that would be fantastic.

avatar image robertbu · Feb 02, 2014 at 04:18 AM 0
Share

You are more likely get help if you post your script attempt.

avatar image Ashish Dwivedi · Feb 02, 2014 at 06:16 AM 0
Share

Can you post your script please?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by supernat · Feb 02, 2014 at 06:26 AM

Steve,

It would go something like this. Create 3 public GameObject variables in your script that you will assign values to in the editor. Assign the spawn point A to one variable, spawn point B to one variable, then assign the prefab to the third variable.

Within your script, add an OnCollisionEnter() or OnCollisionEnter2D() method, and create the missile at whichever spawn point you want using the Instantiate method, passing the starting point as the spawn point. You can pass Quaternion.identity for no rotation.

For further reading: http://docs.unity3d.com/Documentation/Manual/InstantiatingPrefabs.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Spawn a prefab 1 Answer

Play sound on trigger, sound is coming from the trigger 1 Answer

Spawn object problem 1 Answer

Pressing "Fire2" Spawns and removes object on click 0 Answers

Triggers not working - What's wrong with this script? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges