Search Unity

Score on Jumping..

Discussion in 'Scripting' started by mightyjumpsky, Jan 15, 2019.

  1. mightyjumpsky

    mightyjumpsky

    Joined:
    Jan 14, 2019
    Posts:
    15
    Hello,

    Can someone help me to fix my problem, currently i have a player that would be jumping

    into the air. The score is based on how high he can jump, but the problem is when the

    player fall down, the score will also fall down. What i want is when the player fall

    down, the score will not fall down, and when the player continue jump up, the score will

    continue from the last score... Any help appreciated!
     

    Attached Files:

  2. Cyber-Dog

    Cyber-Dog

    Joined:
    Sep 12, 2018
    Posts:
    352
    Can you provide a code snip of the function that controls the score
     
    mightyjumpsky likes this.
  3. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Code (CSharp):
    1. float highestValue = 0.0f;
    2. Transform player;
    3.  
    4. void Update(){
    5.  
    6. if(player.position.y > highestValue)
    7.     highestValue = player.position.y;
    8. }
     
    mightyjumpsky and Cyber-Dog like this.
  4. mightyjumpsky

    mightyjumpsky

    Joined:
    Jan 14, 2019
    Posts:
    15
    Thanks alot @SparrowNest.... I'll try it later.... Later i'll provide snip of the function @Cyber-Dog
     
  5. mightyjumpsky

    mightyjumpsky

    Joined:
    Jan 14, 2019
    Posts:
    15
    I tested and it really work.... Thanks again @SparrowNest