- Home /
Question by
LBernard1431 · Jul 04, 2021 at 01:05 AM ·
codepage
Add a point for character crossing line
i want my game to add a point for every time you cross a line like in the game dune but i dont know how to make 1 go to 2. every time the player is above the line its just adds like 20 more 1's. heres the code for it
// Update is called once per frame
void Update()
{
if (Player.position.y > -0.05)
{
scoreText.text += 1;
}
}
}
Comment
Best Answer
Answer by Nistroy · Jul 04, 2021 at 08:08 AM
You can use Vector2.Distance from th starting point of your game @LBernard1431 . the starting point is the starting point of your reader: normally 0. The addPoint variable will increase the value of range, it's up to you to adjust it according to your needs.
float range = 0;
[SerializeField] float additionPoint = 10f;
public Vector2 startingPoint;
private void Update()
{
range = Vector2.Distance(startingPoint, transform.position) * additionPoint;
}
Your answer
Follow this Question
Related Questions
Convert Audio Beeps And Dashes into Text 0 Answers
GetItemByID error 0 Answers