A couple of Programing Questions for Obstacle dodge course

Hey Folks! I have a couple of programming questions that came up as I am working through the obstacle dodge portion of the udemy course.

  1. Scorer Script - When I press play, my collision count starts at 1, not 0 like in the videos. I suspect it counts the collision with the ground plane, because when I deselect Mesh Collider, the scorer counts correctly, but obviously turning off mesh collider for the ground would throw off other parts of the game. I believe I can fix this using tags, but I don’t know how to code it to say “Don’t count collisions with the ground plane.” any suggestions?

• 2. Time Log- When I initiate Time.time with written statements, it gives me the statement at the correct time, but also continuously gives me that message until I stop the game? How do I program it to give me the statement one time?

Hi Awink,

Welcome to our community. :slight_smile:

  1. You might be right. In many cases, the player collides with the ground on start. This is a known problem which we are going to solve in a later video. Your idea is basically the solution. If you want to challenge yourself, look up tag in the Unity API (not the manual!). There is a code example. If you read it, you’ll very likely recognise your idea.

  2. Without knowing where/how you logged Time.time into your Console (if you did that), I can only guess again: Maybe you used Debug.Log in Update(), which gets called once per frame? If you call Debug.Log in Start(), the message should get logged into your console only once because Start() gets called only once. However, I don’t know what your goal is, so maybe this is not a solution for this problem.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.