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 shadowpuppet · Jul 12, 2016 at 05:29 PM · colliderstriggerschild-to-gameobject

two colliding objects effect a third object

Stumped in this one. I have a gameobject ( a crane) that animates by rotating as well as its arm going up and down. This is activated by the arrow keys. What I am trying to accomplish is that if , while the crane is rotating, the arm of the crane hits an obstacle ( like an " I" beam) that the turret can not rotate in that direction any more ( forcing you to raise the arm to clear the obstacle) . I have tried putting colliders and triggers on just about everything, setting the animation speed to zero, triggerenter, collider enter etc. I can't put a collider on the component with the animation component because that isn't what collides. I have to put a collider on the joint below that so it will move like the arm does. I think it has to do with the collider on the crane being a child of the part with the actual animation component? So here is the script..while rotating left, if the arm hits an obstacle it turns off the script that enables the turret to rotate that way, if you rotate the other way ( triggerexit) the script goes back on. I have tried CollisionEnter and just about everything I can think of. Please help with ANY advice or comments

 using UnityEngine;
 using System.Collections;
 
 public class blockCraneRotate : MonoBehaviour {
 
     private MonoBehaviour rotate;
     GameObject crane;
     GameObject Ibeam;
 
 
 
     void Start () {
         crane = GameObject.Find("CraneTest");
 
         Ibeam = GameObject.FindWithTag("blockcrane");        
         rotate = GameObject.Find("CraneTest").GetComponent<CraneLeft>();
     }
     
     void OnTriggerEnter(Collider other) {
         if(other.tag == "blockcrane")
         {
 
                 rotate.enabled = false;
 
         }
     }
 
         void OnTriggerExit(Collider other) {
             if(other.tag == "blockcrane")
             {
                 
                 rotate.enabled = true;
                 
                 
             }
     }
 }
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by shadowpuppet · Jul 12, 2016 at 06:20 PM

well I figured it out finally put a rigidbody on the arm of the crane with all constraints checked on, useGravity off. the ibeams have a box collider trigger with the below script. Seems simple now. Could have sworn I tried this as one of my many attempts. Now to add a big metal BANG sound. This script goes on the ibeam to the left of the turret arm. A similar one goes to the rightside to stop rotation going right. Actually each I beam will need two trigger zones...one for the inside, and one on the outside because if you raise the arm to go over the ibeam, then go back from where you came you's need the script that blocks it from that direction as well

 using UnityEngine;
 using System.Collections;
 
 public class blockCraneRotate : MonoBehaviour {
 
     private MonoBehaviour rotate;
     GameObject crane;
     Animation anim;
     private AudioSource motor;
 
 
     void Start () {
         anim = GameObject.Find("CraneTest").GetComponent<Animation>();
          rotate = GameObject.Find("CraneTest").GetComponent<CraneLeft>();
         motor= GameObject.Find("CraneTest").GetComponent<AudioSource>();
     }
     void OnTriggerEnter(Collider other) {
         rotate.enabled = false;
         anim["craneRotate"].speed = 0f;
         motor.Pause();
     }
  
     void OnTriggerExit(Collider other) {
     rotate.enabled = true;
     //anim["craneRotate"].speed = 1f;
     }
 } 
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

61 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

Related Questions

3D Trigger collider slows player moved by forces 0 Answers

onTriggerEnter returns wrong object's attribute 1 Answer

multiple objects with triggers that need to ignore the triggers but still collide with eachother? 0 Answers

Check if character has entered trigger, if it has play animation on character. 1 Answer

Trying to get controller to trigger OnTriggerEnter, no avail 0 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