Question by 
               Drowned_horse · Aug 20, 2020 at 05:13 PM · 
                c#score systemendless runnerthanks  
              
 
              how to create a score multiplier?
i am a making an endless skiing game, and already have a scoring system, however i want to add a score multiplier based on the number of consecutive tricks done without touching the ground. heres my script so far:
 public class tricksScore : MonoBehaviour
 {
 
 private float flips = 0;
 private float deltaRotation = 0;
 private float currentRotation = 0;
 private float WindupRotation = 0;
 public static Rigidbody2D rigbod;
 public Text scores;
 private int trickscore;
 private int iflip;
 private int oldscore;
 private int incInScore;
 public float speed;
 private float counter;
 private int flipscore;
 private int rockDestroy;
 private bool grounded;
 private int multiplier = 1;
  // Collision2D coll;
 
 
 // Start is called before the first frame update
 void Start()
 {
     speed = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>().speed;
     scores = GameObject.Find("score").GetComponent<Text>();
     rigbod = GameObject.FindGameObjectWithTag("Player").GetComponent<Rigidbody2D>();
     grounded = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>().grounded;
 }
 
 // Update is called once per frame
 
 void Update()
 {
 
     rigbod.velocity = new Vector2(speed, rigbod.velocity.y);
     deltaRotation = currentRotation - rigbod.transform.eulerAngles.z;
     currentRotation = rigbod.transform.eulerAngles.z;
     if (deltaRotation >= 300)
         deltaRotation -= 360;
     if (deltaRotation <= -300)
         deltaRotation += 360;
     WindupRotation += (deltaRotation);
     flips = WindupRotation / 340;
     iflip = (int)flips;
     iflip = iflip * -1;
     flipscore = iflip * 10;
 
     trickscore = flipscore + rockDestroy;
     scores.text = "score " + (trickscore * multiplier);
 
     incInScore = trickscore - oldscore;
     if (incInScore >= 10)
     {
         oldscore = trickscore;
     }
     
     //speed += (Mathf.Round(incInScore)) / 100.0f;
   
     if (incInScore > 1 && incInScore <= 10)
     {
         speed = speed + 0.15f;
         counter += 3f;
     }
      if (incInScore > 10 && incInScore <= 20)
     {
         speed = speed + 0.25f;
         counter += 3f;
     }
      if (incInScore > 20 && incInScore <= 50)
     {
         speed = speed + 0.50f;
         counter += 3f;
     }
      if (incInScore > 50 && incInScore <= 100)
     {
         speed = speed + 0.75f;
         counter += 3f;
     }
      if (incInScore > 100 && incInScore <= 200)
     {
         speed = speed + 1f;
         counter += 3.5f;
     }
      if (incInScore > 200)
     {
         speed = speed + 2f;
         counter += 4f;
     }
 
     if (incInScore > 5 && grounded == false)
     {
         multiplier = multiplier + 1;
     } else if (grounded == true)
     {
         multiplier = 1;
     }
 
 
      if (speed > 5.15f)
     {
         speed -= 0.05f * Time.deltaTime;
     } else if (speed == 5.15f)
     {
         speed = 5.15f;
     }
      
     counter -= 1.0f * Time.deltaTime;
 
     if (counter < 0)
     {
         counter = 0;
     }
 
     if (incInScore >= 10)
     {
         incInScore = 0;
          
    }
 
     if (incInScore < 0)
     {
         incInScore = incInScore * -1;
     }
 }
 private void OnCollisionEnter2D(Collision2D coll)
 {
     //counter = GameObject.FindGameObjectWithTag("Player").GetComponent<tricksScore>().counter;
     if (counter > 0)
     {
         if (coll.collider.tag == "rock")
         {
             Destroy(coll.gameObject);
             speed = speed + 0.15f;
             rockDestroy = rockDestroy + 5;
             counter = counter + 2f;
         }
         
     }
 }
 
 
 }
 
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Getting an Exception on Endless Runner 3D game 1 Answer
How do I make a Score and Highscore thingie in game over screen 2 Answers
When should I use static fields/methods? 2 Answers
spawning coins in an endless runner. pausing function for a specific time? 1 Answer
In the next scene show the score using player prefab before next level 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                