Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Jlmccart01 · Dec 30, 2015 at 08:20 PM · script.objects

How does one make an object appear after completing an objective.

So I have no idea how to make scripts and I have looked around, but have not found what I am looking for in particular. I need a way to make one of my objects (a teleporter) appear after picking up a coin. This way the character or player can teleport to the next level. This is the tutorial area I am working with and was wondering how to make this happen. Thanks!

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 Towtow10 · Dec 31, 2015 at 03:52 AM 0
Share

Is the teleporter already there and just invisible? or do you want it to be created from a prefab?

avatar image antiquote · Dec 31, 2015 at 06:29 AM 0
Share

Okay first off, I need you to adopt a new $$anonymous$$dset. If you have a task, break it down into smaller steps. If you're unsure of how to complete some of these steps, break it down further. With that being said your task is to make a Teleporter appear after picking up a coin correct?

So how would we pick up a coin? It would be simple to us, although in game development sometimes wee have to cut corners. So lets break it down into smaller steps. In $$anonymous$$ario, coins are present, but once you touch a coin it disappears. Let's do that.

First the coin is existing, and then once we touch it, it's gone. Touching works through colliders. So I would have the coin contain a script to constantly check if it's colliding with something. And once it does we destroy it. There by "Picking it up." To accomplish this i would start off by having this snippet:

 void OnCollisionEnter ( Collision collision )
 {
     Destroy(this.gameObject);
 }

Hold this $$anonymous$$dset and build your knowledge with it. I hope this information helps you and gives a starting point in scripting and the awesome world in game development.

avatar image Jlmccart01 antiquote · Dec 31, 2015 at 07:05 PM 0
Share

Okay. So I already have a personal script to pick up coins as well as count the coins. I just do not know what form of functions I must create in order to have an object appear after touching that coin. I do not want a script given, but rather a way to understand what I need to do. As I said before I am completely new to scripting and I want to learn. I have looked for tutorials, but all they do is give scripts with no explanation. I want some help understanding the functions and how to complete this task thats all. Thanks!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by EpicPandaGamer25 · Dec 31, 2015 at 07:25 PM

@ Jlmccart01

Put this on your coin pickup script(should be on your player):

 //New Variables
 public GameObject teleporter; //Assign this gameObject in the inspector
 
 void OnTriggerEnter (Collider col) {
     if (col.gameObject.name == "COINNAMEHERE") { //COINNAMEHERE should be the name of your coin gameObject
         coins += 1; //Whatever your coin counter variable is replace coins with that
         Destroy(col.gameObject);
         teleporter.SetActive(true); //Make sure that the teleporter is disabled by default in the inspector
     }
 }
Comment
Add comment · Show 2 · 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
avatar image Jlmccart01 · Dec 31, 2015 at 08:31 PM 0
Share

So what would the coin counter variable be? I am new to all this ter$$anonymous$$ology and I have tried everything, but I cannot figure out what I should be putting there to get the script to work?

avatar image Jlmccart01 · Dec 31, 2015 at 08:51 PM 0
Share

So this is the code that I have modified a little, but I keep getting errors especially with the coin += 1 as it does not like the += part. Am I confusing something here?

using UnityEngine; using System.Collections;

 public class TeleporterAppear : $$anonymous$$onoBehaviour {
 
     public GameObject coin;
     public GameObject teleporter;
 
     void OnTriggerEnter (Collider col) {
         if(col.gameObject.name == "Coin") {
             coin += 1;
             Destroy (col.gameObject);
             teleporter.SetActive (true);
         }
     }
 }

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

38 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 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

An object inside an object class 0 Answers

drag and merge object 0 Answers

how to contain a object inside in a specific area and move all of the items inside that are all together? 0 Answers

[Absolute beginner] Play animation on trigger (trigger = several fallen objects) script 1 Answer

How would I create a script that spawns objects more frequently as time goes on, then stops after a certain point/amount of time? 1 Answer


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