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 tommyfraser · May 11, 2020 at 08:17 AM · iosxcodeinput.touch

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

Hey,

I am reasonably new to Unity and a Hobbyist programmer at best. I am in the middle of creating my 2nd mobile game.

I am at a frustrating point in that my game works within Unity and on the Unity Remote app in iOS, however as soon as I compile it in Xcode it refuses to work in the same way.

The point it appears to be sticking at is because I am waiting for a user to have held down a tap by updating a variable and adding Input.deltaTime. However having output this deltaTime information to a debug log it appears that deltaTime is showing up as always 0 so the function never works. Please see my code below.

Thanks in advance.

 using UnityEngine;
 
 public class TouchController : MonoBehaviour
 {
     //variables
     enum State
     {
         startMode,
         scopeMode,
         aimMode
     }
 
     State currentState;
    
     public CameraController2 cameraController2;
     public GameObject arrowObject;
 
     public ArrowPutterPivotController arrowPutterPivotController;
 
     public BallController ballController;
     public PutterController putterController;
 
     private float touchStationaryTime;
     private Vector2 scopeStartVector;
 
 
     //functions
     private void Start()
     {
 
         currentState = State.startMode;
  
         arrowPutterPivotController.hideArrow();
     }
 
     void Update()
     {
         
         //check for input
         if (Input.touchCount > 0)
         {
             
            
             //get first touch details
             Touch touch = Input.GetTouch(0);
             TouchPhase phase = touch.phase;
             Debug.Log("TouchPhase: " + phase);
 
 
             //check if touch has just begun
             if (phase == TouchPhase.Began)
             {
                
                 //reset state to normal scoping
                 currentState = State.startMode;
                 touchStationaryTime = 0f;
                 scopeStartVector = Vector2.zero;
          
                 arrowPutterPivotController.hideArrow();
                 
             }
 
             //check if touch has has stayed still
             if (touch.phase == TouchPhase.Stationary && currentState == State.startMode)
             {
 
                 
                 //Increase touchstationarytime by time since last touch press
                 Debug.Log("touch.deltaTime: " + touch.deltaTime);
                 touchStationaryTime += touch.deltaTime;
                 Debug.Log("touchStationaryTime: " + touchStationaryTime);
                
 
                //Check if touch press is over 1 second
                 if (touchStationaryTime > 0.5f && ballController.stationary == true)
                 {
                     Debug.Log("if (touchStationaryTime > 0.5f && ballController.stationary == true)");
                     currentState = State.aimMode;
                     arrowObject.SetActive(true);
                     
                     arrowPutterPivotController.showArrow();
                     scopeStartVector = touch.position;
                 }
                 //check time of being in stationary status
             } else if (touch.phase == TouchPhase.Moved && currentState == State.startMode)
             {
              
                 currentState = State.scopeMode;
             }
 
 
         if ((touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary) && currentState == State.aimMode)
             {
               
                 Vector2 diffVector;
                 diffVector = scopeStartVector - touch.position;
 
                 arrowPutterPivotController.setRotation(diffVector);
                 arrowPutterPivotController.resizeArrow(diffVector);
             }
 
             if (touch.phase == TouchPhase.Ended && currentState == State.aimMode)
             {
                 Vector2 diffVector;
                 diffVector = scopeStartVector - touch.position;
 
                 putterController.hitBall(diffVector);
               
                 arrowPutterPivotController.hideArrow();
                 scopeStartVector = Vector2.zero;
                 currentState = State.startMode;
             }
 
             if (touch.phase == TouchPhase.Moved && currentState == State.scopeMode)
             {
                 
                 cameraController2.Spin(touch.deltaPosition);
             }
    
         }
     }
 
 }
  
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

0 Replies

· Add your reply
  • Sort: 

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

161 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

Related Questions

xCode > testFlight 3 Answers

iOS9: App will load perfectly when launched from XCode, fails to load resources (eg textures) when launched from Springboard 0 Answers

RenderTexture runtime error on app load on iOS 1 Answer

unity3d xcode build for iOS “object is not signed at all” 0 Answers

Iphone 4s simulator problem ? 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