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 /
This question was closed Feb 21, 2013 at 11:49 PM by thatanimator for the following reason:

Problem is outdated

avatar image
0
Question by thatanimator · Feb 21, 2013 at 11:49 AM · ontrigger

OnTriggerEnter/Stay/Exit Assign/Clear variable

alt text

Hello! I'm gonna keep this fast and simple :)

Picture shows the player and 3 trigger boxes. I want to be able to move around a level full of these, when I hit one I want that particular trigger box to become the target for where the player places a marker down, so that where ever the player is standing, the marker is always placed in the middle of the square he's on, even if he's closer to the corner or edge of it.

The space between these triggers is going to be very small, but they have to assign and clear themselfs as the player moves around. I don't want to place a marker on the square I was previously on of course.

Right now this kind of works but only for the first trigger that I enter. It gets assigned to the players "where to create cube (marker) variable" and you can place the marker by clicking on the screen. However, if I move just an inch, the target gets cleared and nothing ever assigns again. At best, I've managed to get it to work so that only that initial target can get re-assigned. But the other ones keep ignoring me.

 var createmarkerscript : createmarkerscript;
 
 function Update(){
 
 }
 function OnTriggerEnter (collider : Collider) {
         if (collider.gameObject.tag == "Player"){
             createmarkerscript.place = gameObject;
            }
 }
 
 function OnTriggerExit (collider : Collider) {
             createmarkerscript.place = null;
 }

Thats the script that is attatched to the target trigger boxes, that I want to assign to the players target.

 var SingleMarker : GameObject;
 var place : GameObject;
 
 function Update () {
     if(Input.GetMouseButtonDown(0))
     var SingleMarker : GameObject = Instantiate(SingleMarker, place.transform.position, place.transform.rotation);
 }


This is what is currently on the player. Where "place" is the target where we want to create the marker.

So the problem again (and in short) is:

Want to assign GameObjects to players target using triggers. Only works once if even. Want to clear the target when the player steps of a trigger and onto another one, currently only clears but never re-assigns.

Any ideas? I'm gonna assume I don't want to do this in an Update function as I'm going to have quite a few of these boxes on each level and that would probably be a lot of wasted calculations.

Hope you guys can figure something out! Thanks!!

Comment
Add comment · Show 1
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 thatanimator · Feb 21, 2013 at 01:17 PM 0
Share

NEVER $$anonymous$$IND (??) It seems to have solved itself.. for now

I'll leave this question open just a bit longer while I debug it (a day or two). If it breaks down it's best if I just use this topic again.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

9 People are following this question.

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

Related Questions

kinematic trigger with static collider-no trigger message? 0 Answers

Problem with OnTriggerExit 1 Answer

DroppableMover Referenced - 3DPlatformer 1 Answer

Change gravity point on trigger 0 Answers

How do you assign a gameObject to an "Animator" with script? 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