Quantcast
Channel: Latest Questions by greatUnityGamer
Viewing all articles
Browse latest Browse all 99

Why would I be able to change values through the Inspector for public vars, but i can't do it through code?

$
0
0
I have Energy Bar toolkit. It's a product i got. it has variable currentValue for setting the current bar amount. It's in the inspector so you can set it manually by typing desired value. But for some reason, when i try to change it through scripting it doesn't work at all In My class i have this: public class Player{ EnergyBar b; OnCollisionExit( Collision collider){ if( collider is of tag "BOMB" ){ //player gets hit b.currentValue -= 5; //or i do it through a method b.setcurrentValue( -5 ); } } } Then in the INspector for my Player object which is loaded to the viewport. i select it and then in it's inspector tab it has an Energy field..and i drag the EnergyBar gameobject onto it. It should work but it doesn't. When my player collides with and explosion object, the Energybar does not decrease

Viewing all articles
Browse latest Browse all 99

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>