Hello everyone, I’m making a race game, but I’m having some problems with the speedometer.
I can calculate the speed, but not set it in another scene were the hud is.
Here is an example of the problem that I’m having:
Can you describe the other two ways ? I am always willing to learn something new.
Oh, if one of them is by sending messages using logic brick, than there is just one more.
This is faster, but only because I dropped the tick rate to 6, instead of 0.
You really don’t need 60 frames per second updates for an analog speedo.
10 frames per second looks just fine.
On starting, the speedo’s script looks through the active scenes to find the player object.
It then stores the reference to that object as a string property.
From there it is very quick to call that object from the property, and you can call the properties of that object too.
ex.
speedo = own
player = own[‘player’] (got from a list)
player speed = own[‘player’][‘speed’]
I use this method a lot if I want to get properties or locations from a lot of things in the main scene. For example in my recent space combat game I used a radar system which would check the nearest 12 friends/enemies every second or two through a (for in list) loop, then used thier location/vector to point arrows to them every 6 ticks.
It is probably just as easy to got the same info using game logic, but this way I can have access to every property of the linked object from the HUD. The HUD script becomes easier to manage centrally, rather than having to go through all the player and enemy scripts to make changes.