Ambiera ForumDiscussions, Help and Support. |
|
[ 1 2 ] Page 1 of 2 |
|
|||||
|
https://drive.google.com/file/d/1kdpB-ZJTLiEpH1DSOBscTt8ep0FTQCFo/view?usp=sharing this is how you can setup a health bar in your game for any question or any query feel free to ask |
||||
|
Maybe it's an error with my computer but it doesn't seem to work for me.... Healthbar doesn't move. Bullets don't hit enemy. Enemy can't hit player. Player can walk through enemy. ...maybe the collision isn't working? https://streamable.com/wqmzp6 |
||||
|
@VP the health bar only decreases from one enemy which can't be killed. the first one you meet, I believe. the rest can be killed but do no damage to you. |
||||
|
Ah OK, cool. Thanks. I'll download it again. I probably just killed the first enemy by instinct before he had chance to attack. lol. |
||||
|
I can write the health to a 2d Overlay but I can not access it via a script in a Scripting window or in action/behavior
i think i tried every possible $ $ combination any suggestions are welcome |
||||
|
hash sign not printed there, buttt the looks like =||= |
||||
|
I would imagine it's: |
||||
|
|
||||
|
@douwedabbe you are using a variable name as a property. Don't use ccbGetSceneNodeProperty for the health variable. Instead you need to use. ccbGetCopperCubeVariable("hashtagclerk.health") Also while accessing properties you did a typo in "player" And wrote it "pl;ayer" and you are using so many symbols with the variable name thats why you are getting illegal character errors. However if you didn't had performed typo and used symbols it still would have throw you an error cause you were using variable as a property and it will throw an errror property doesn't exist. To fix them simply replace your line with this var myHealth = ccbGetCopperCubeVariable("hashtagclerk.health"): Replace "hashtag" with hash symbol And it should work fine. |
||||
|
thanks overlooked that then corrected it for getting value out but not when assigning creating another creazy bug always take code back into proper editor with syntax highlighting |
||||
|
How do I access thru some interchangable variable the health of a bunch of players? "=||=someplayer.health"
|
||||
|
[quote]DouweDabbe wrote: How do I access thru some interchangable variable the health of a bunch of players? "=||=someplayer.health" String.fromCharCode(35) you can replace with =||= if you want but not needed. //this will be the name of variable. var a = String.fromCharCode(35) + ccbGetSceneNodeProperty(this.node,"Name") + ".health"; //this will be the value of variable. var b=ccbGetCopperCubeVariable(a); make sure to print it .. so you see if name is correct and does value responds to it. print( "Name " +a +" value " +b); to scan a punch of nodes you can use numbers in names and use it like this.. i used to use AI1 AI2..and so on And in for loop i just included name "AI"+i OR scan folder.. var max = ccbGetSceneNodeChildCount(ccbGetSceneNodeFromName("FolderName")); for (var i = 0; i < max; i++) { var t = ccbGetChildSceneNode(ccbGetSceneNodeFromName("FolderName"),i); var current_name=ccbGetSceneNodeProperty(t,"Name"); } ((nodes must be in FolderName folder and will be scanned)) (i didnt test this script so may include errors but should give idea of it) |
||||
|
Thank You Sven, but still not working, I report it as a bug |
||||
|
DouweDabbe wrote: Thank You Sven, but still not working, I report it as a bug You have : instead of ; at the end of line. ar playerHealth = ccbGetCopperCubeVariable("=||="+playerName.toString()+".health"): <-- error ccbGetCopperCubeVariable not js function var playerHealth = ccbGetCopperCubeVariable("=||="+playerNode.toString()+".health"): <-- error same message |
||||
|
no not true, look better https://www.ambiera.com/forum.php?t=10295 |
[ 1 2 ] Page 1 of 2 |
|