Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > CopperCube > Programming and Scripting
that's how you can setup custom health bar
Author Text

mrandy
Registered User
Quote
2021-06-10 19:00:58

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


VP
Guest
Quote
2021-06-16 12:58:31

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


monika_5
Registered User
Quote
2021-06-18 09:07:16

@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.


VP
Guest
Quote
2021-06-18 09:49:15

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.


DouweDabbe
Guest
Quote
2021-06-21 12:36:42

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


var player = ccbGetSceneNodeFromName("clerk");
print("player="+player);

var myHealth = ccbGetSceneNodeProperty(pl;ayer, "@$%&player.health*&^%$@"):
print("myHealth="+myHealth);

error = : illegal charcter
or
error : reference error
or
object unknown



i think i tried every possible $ $ combination
any suggestions are welcome


DouweDabbe
Guest
Quote
2021-06-21 12:40:29

hash sign not printed there, buttt the looks like

=||=


VP
Guest
Quote
2021-06-21 16:35:06

I would imagine it's:




veganpete
Registered User
Quote
2021-06-21 16:35:47




just_in_case
Registered User
Quote
2021-06-21 16:51:51

@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.


DouweDabbe
Guest
Quote
Yesterday

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


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "In?ernational" (you are not logged in)


Text:

 

  

Forum Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons