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 /
avatar image
0
Question by banyiknandor1 · May 01, 2018 at 06:42 PM · scripting problemtrigger

Enable Trigger On Trigger

 var obj : GameObject;
 
 function Start () {
     obj.GetComponent.<Collider>().BoxCollider.Collider = false;
 }
 
 function OnTriggerEnter (other : Collider) {
     if(other.gameObject.tag == "Player") {
         obj.GetComponent.<Collider>().BoxCollider.IsTrigger = true;
         obj.GetComponent.<Collider>().BoxCollider.Collider = true;
     }
 }

   

I wrote this script but it's not working, any suggestions? :(

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 the_genius · May 01, 2018 at 07:22 PM 0
Share

What do you mean by "not working"? Are you getting compiler errors? Or is it not working at runtime?

avatar image Kciwsolb · May 01, 2018 at 07:45 PM 0
Share

You have a lot of issues in what you wrote. For one, you seem to be mixing C# and Js together. I suggest you learn a bit about program$$anonymous$$g and scripting in Unity before you go any further. I am afraid, based on what you have written so far, there is no way I could help you without writing your script for you. But you wouldn't learn that way, and that is not really the point of these forums. I suggest you start by learning a bit about program$$anonymous$$g in general, and then learn a bit about scripting in Unity. Pick one of the two languages and stick to it. Personally, I suggest C# since there is more Unity specific information and tutorials about it.

Here is a great site that can $$anonymous$$ch you the basic C# syntax: https://www.sololearn.com/Course/CSharp/

Here are the Unity scripting tutorials: https://unity3d.com/learn/tutorials/s/scripting

Now, someone might come along and try to write a script for you anyways, but believe me when I say that you are better off spending time learning how to code for yourself than you are trying to ask other people to write your game for you one script at a time. If you get stuck with something specific, be sure to let us know so we can help you out. But it is hard to help with a question that is so broad.

avatar image SharkoFR · May 02, 2018 at 04:42 PM 0
Share

You can only create an empty object with a trigger collider, set it not active and when you want you can active it!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by SharkoFR · May 01, 2018 at 07:30 PM

Hum, javascript is not currenlty used in unity.

Comment
Add comment · Show 5 · 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 the_genius · May 01, 2018 at 07:33 PM 0
Share

As far as I am aware, unityscript (aka javascript) still works they've just removed the menu item. I don't think it is being removed until 2018.1 or 2018.2.

avatar image SharkoFR the_genius · May 02, 2018 at 04:40 PM 0
Share

Hi, unityscript is now officially C# :)

avatar image banyiknandor1 · May 01, 2018 at 09:29 PM 0
Share

JavaScript works fine for me in some other scripts. But can you please write a C# suggestion? I'm a bit dumb for C# :(

avatar image the_genius banyiknandor1 · May 01, 2018 at 10:14 PM 0
Share

Nobody is too dumb for C#. It just takes time and practice. I doubt anyone is going to write the code for you. You need to learn how to do it yourself. Unity provides some great learning resources. I'd suggest watching the beginner videos here and going through some of their projects.

avatar image banyiknandor1 the_genius · May 01, 2018 at 10:39 PM 0
Share

Well this will take a long time :/ But thank you

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

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

OnTriggerEnter() is occasionally not occurred 1 Answer

How can i detect by script when a character enter a hole in object ? 1 Answer

In-Game Tutorial with special actions in special areas. (Shooter) 0 Answers

Can child game object with OnTriggerEnter function use parent game object's collider? 2 Answers

Void OnTriggerEnter not working 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