|
Post by thehobliks on Aug 7, 2014 21:56:53 GMT
i'm not sure what's going on so hopefully someone will know the answer to this. i have a clickable object with a killable script attached to it. i'm using a world variable for the hit points. while the game is running i can see the hit pits decrease on the killable script with each mouse click and the object is destroyed once it reaches zero, but the variable isn't updating in the world variables prefab. as far as i can tell the listeners are set up so i'm not sure what could be causing this. most likely it's something simple that i'm overlooking.
|
|
|
Post by DarkTonic Dev on Aug 7, 2014 23:17:10 GMT
Using the World Variable for a value will not update the world variable ever by itself. That's for reading the value only. In Killable, only the Death World Variable Modifiers section will modify World Variables (and there's also one for every time the Killable is damaged).
The point of using a World Variable for hit points is only to provide a non-hard-coded number of hit points.
If you want the World Variable to be synchronized with the player's current hit points, you will need to subclass Killable and write a line of code in TakeDamage method to do that. Note that it might cause you other problems though. One off the top of my head is that if your player has more than 1 life, the 2nd life player will be spawned with zero hit points and instantly die.
So what are you trying to achieve by using a World Variable for hit points? Maybe there's a better way to do it.
|
|
|
Post by thehobliks on Aug 8, 2014 1:59:34 GMT
this is what i have set up. i have objects (enemies) that appear on the screen in random places. when you click an enemy it will be destroyed and add 1 to a world variable named score. you can see that variable update in both the killable script that is attached to the object and you can see it update in the world variable prefab in real time.
now i have a power up that i also have connected to world variable. whenever you click the power up it should subtract 1 from the world variable that it is connected to. basically the exact same thing i did but in reverse (instead of plus 1 it's minus 1). you can see the variable update in the killable script attached to the power up but it doesn't update in world variables. i was able to achieve all of this without writing additional code.
|
|
|
Post by DarkTonic Dev on Aug 8, 2014 4:17:01 GMT
For the power up, if you're doing 1 damage to it, then you can use the Damage World Variable Modifiers in Killable to modify the correct World Variable with a minus 1. That should do it.
|
|
|
Post by Nguyen on Sept 24, 2014 2:53:39 GMT
Is there anyway I modify World Variable with enemy attack point is parameter ? or update World variable with player current hit point ? For example: -I link my player's hit point to world variable. -My enemies have different attack points. -How can I use Damage World Variable Modifiers with Enemy Attack Point ? or How can i update world variable with player hit point ?
|
|
|
Post by DarkTonic Dev on Sept 24, 2014 4:31:28 GMT
Updating world variable with player hit points automatically (option) is on the to do list, I should be coding that in the next 1 or 2 versions. There's currently no way to access the damage world var modifiers from Taking Damaging method in the listener, but it could be added if you think it's useful?
|
|
|
Post by Nguyen on Sept 24, 2014 5:04:49 GMT
Thanks for quick replying !
|
|
|
Post by DarkTonic Dev on Sept 24, 2014 6:28:35 GMT
No problem.
|
|