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 $$anonymous$$ · Sep 08, 2017 at 10:31 AM · input.touchiphonetouch

Event trigger not calling function C#

Hi Guys,

I'm trying to make a simple app specifically for the iPhone. Yes I know there is one in the asset store but I want my own version. So I have a cube rotating and I would like the cube to rotate the other way whenever I tap on the cube. I have an Event Trigger attached to the cube and a script controlling it. The cube is rotating properly. I'm testing it using Unity 2017 at the moment. For some reasons it's not reacting to my clicks and it's not even calling the function in the script. I dunno why. Someone who had this problem or knows how to solve this? What am I missing?

Script`float x,y,z; Vector3 rotationDirection, upRotation, downRotation; GameObject cam; CameraController camScript;

 void Awake()
 {
     x = 75; y = 60; z = 45;
     upRotation = new Vector3(X, Y, Z);
     rotationDirection = upRotation;
     cam = GameObject.Find("Main Camera");
     camScript = cam.GetComponent<CameraController>();
 }
 
 public void ChangeDirection()
     {
     Debug.Log("Did not reach here..");
     if (rotationDirection == upRotation)
     {
         x = -X; y = -Y; z = -Z;
         downRotation = new Vector3(X, Y, Z);
         rotationDirection = downRotation;
         camScript.SetDirection(Vector3.left);
     }
     else
     {
         x = Mathf.Abs(X); y = Mathf.Abs(Y); z = Mathf.Abs(Z);
         upRotation = new Vector3(X, Y, Z);
         rotationDirection = upRotation;
         camScript.SetDirection(Vector3.right);
     }
     }

 // Update is called once per frame
 void Update () {
     transform.Rotate(rotationDirection * Time.deltaTime);
 }`

alt text

Thanks in advance!

triggerissue.png (53.8 kB)
Comment
Add comment · Show 4
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 Positive7 · Sep 08, 2017 at 10:35 AM 0
Share

Note the "No Function" drop down in Event Trigger click and look for ChangeDirection() method.

avatar image $$anonymous$$ Positive7 · Sep 08, 2017 at 10:56 AM 0
Share

Sharp of you but that's not the issue

avatar image Positive7 $$anonymous$$ · Sep 08, 2017 at 11:16 AM 0
Share

Sorry, it is too early in the morning. Event Trigger is for UI. You want to use Touch function on that : https://docs.unity3d.com/$$anonymous$$anual/$$anonymous$$obileInput.html https://unity3d.com/learn/tutorials/topics/mobile-touch/multi-touch-input

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by cgarossi · Sep 08, 2017 at 01:51 PM

You have to specify a function to run otherwise it won't do anything

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

69 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

Related Questions

move a GameObject based on Input.GetTouch 1 Answer

Inputs names 1 Answer

how to detect a mobile double tap, and a long press. PS. I already have swipe detected. 0 Answers

Input.deltaTime always returns 0 in Xcode, working in Unity Remote app 0 Answers

Add impulse force using input.touch 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