Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

need a C# Android Expert

Discussion in 'Scripting' started by m-y, Feb 19, 2015.

  1. m-y

    m-y

    Joined:
    Sep 22, 2013
    Posts:
    470
    hello
    let me explain what i did
    and what i am trying to do now
    First : what i did ?
    i just make the ball change it's translation depend on x , z position change
    what i mean is
    in the beginning of the game
    the ball move in the z Axis
    then when ball.z <= value
    the ball start to move in x Axis
    and etc ...

    ok ?

    secound
    i am using swapping for controll
    so , what i want is to make the swapping able to work correctly
    in x , z position axis
    when the ball change it is translation

    so when i try to call it
    no error
    but the condtion doesn't work at all
    there is no anything happen cause of these conditions
    Notes : the code work well without the conditions , but i need conditions cause of translation change nochange.png
    i hope you understand what i mean
    and u can help me :D
    thank
     
  2. Mabenan

    Mabenan

    Joined:
    Feb 7, 2014
    Posts:
    132
    Please use Code Tags with code comments, its difficult to read code in the picture with the Arrows over it.
     
  3. m-y

    m-y

    Joined:
    Sep 22, 2013
    Posts:
    470
    ??????????????????
     
  4. Mabenan

    Mabenan

    Joined:
    Feb 7, 2014
    Posts:
    132
    You can log the Value of takeit.ball.z with Debug.Log(). But what to you expect to happen?
     
  5. Mabenan

    Mabenan

    Joined:
    Feb 7, 2014
    Posts:
    132
  6. m-y

    m-y

    Joined:
    Sep 22, 2013
    Posts:
    470
    i think no need for that
    the code is clear from this pic
     
  7. m-y

    m-y

    Joined:
    Sep 22, 2013
    Posts:
    470
    ok i moved the condition to start method
    and it is give me error
    takeit.png

    and that is the error


    NullReferenceException: Object reference not set to an instance of an object
    Lev4_sphere_ballmevement.Start () (at Assets/Lev4_sphere_ballmevement.cs:19)
     
  8. Mabenan

    Mabenan

    Joined:
    Feb 7, 2014
    Posts:
    132
    are takeit and takeit.ball already initalized at this point?
     
  9. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    Make sure ball.z is actually changing, as you don't provide the code to show how this is populated I'd guess that's the issue. Also in c# 1172.23 should really be written as 1172.23f if it's a float.