Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Car Tutorial for Android

Discussion in 'Android' started by Vancete, Mar 21, 2012.

  1. Vancete

    Vancete

    Joined:
    May 3, 2010
    Posts:
    198
    I'm trying to port Car Tutorial to Android, but when I switch the platform to Android, I get a lot of errors.
    Is there the Car Tutorial ported over the forum?
    Thanks and sorry for my bad english:D
     
  2. TeotiGraphix

    TeotiGraphix

    Joined:
    Jan 11, 2011
    Posts:
    145
    The Car tutorial is very complicated. I doubt just changing the build to Android you are even going to get close to running that game.

    One, you need to figure out how you are going to deail with Input, Two any javascripts need to have #pragma strict to enable strict compiling for performance (this could mean a bunch of refactoring). Three, who knows what other errors come up after you have managed to kill the first two batches.

    Mike
     
  3. tigerfoot

    tigerfoot

    Joined:
    Nov 2, 2009
    Posts:
    132
    It is much easier to port Andrew Gotow's car tutorial. All i had to change was the input method if i remember correctly.
     
  4. TeotiGraphix

    TeotiGraphix

    Joined:
    Jan 11, 2011
    Posts:
    145
    Do you have a link for that?

    Mike
     
  5. tigerfoot

    tigerfoot

    Joined:
    Nov 2, 2009
    Posts:
    132
    Here. I dont have my laptop with me (my ported version is there)

    Change this part of code:
    Code (csharp):
    1.  
    2. // finally, apply the values to the wheels. The torque applied is divided by the current gear, and
    3.     // multiplied by the user input variable.
    4.     FrontLeftWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * Input.GetAxis("Vertical");
    5.     FrontRightWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * Input.GetAxis("Vertical");
    6.        
    7.     // the steer angle is an arbitrary value multiplied by the user input.
    8.     FrontLeftWheel.steerAngle = 10 * Input.GetAxis("Horizontal");
    9.     FrontRightWheel.steerAngle = 10 * Input.GetAxis("Horizontal");
    10.  
    Change Input.GetAxis with Input.acceleration, and that should be it.
     
  6. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    I am working on a racing game for iOS and started with the car Tutorial. I got it to work, but with MAJOR changes. I wouldn't recommend this approach. If I were doing it again I wouldn't do this. Try one of the car packages in the asset store.
     
  7. jessica1986

    jessica1986

    Joined:
    Feb 7, 2012
    Posts:
    621
    When I changed to Input.acceleration.x and same for y.....while exporting it to android 10 errors for SmoothFollow.js is coming 'unknown identifier' for many variables
     
    Last edited: Apr 2, 2012
  8. augasur

    augasur

    Joined:
    Mar 4, 2012
    Posts:
    133
  9. jessica1986

    jessica1986

    Joined:
    Feb 7, 2012
    Posts:
    621
    Im lookin out for the solution to my problem
     
  10. jessica1986

    jessica1986

    Joined:
    Feb 7, 2012
    Posts:
    621
    can any1 help me on dis
     
  11. TeotiGraphix

    TeotiGraphix

    Joined:
    Jan 11, 2011
    Posts:
    145
    This probably means that you don't have variables by type defined in the script scope.

    Can you post the lines of code that are throwing the error?

    Mike
     
  12. arshiyan

    arshiyan

    Joined:
    Aug 24, 2009
    Posts:
    8
    remove SmoothFollow.js and import scripts package again
     
  13. tigerfoot

    tigerfoot

    Joined:
    Nov 2, 2009
    Posts:
    132
    add "var" in front of those undefined variables in SmoothFollow.js and it wont give you any errors.