Download

My First Go at BP nothing works as expected

i have 3 scripts running
Red rotates a coin
Blue Destroys the coin when we touch it. Adds 1 to the total
Green logs total

when i hit 0{Green} it doesnt match what total collected is

can anybody give a quick look at this and let me know what i’m doing wrong.

00160967f413678ec904af7da5b7f96cb58b5f7c.png

Red Script:

  • where do you set IsVis to true? Are you sure its true at beginning?
  • Random Float times 5 feed for delta. Range of float is quite big then you multiply it by 5. Instead do: “random float in range” set range to-180 …180 or 0 … 360

Blue script:

  • if isVis is never true blue script will be never executed
  • if total collected is variable in coin you need to move that somewhere else, also its safer to destroy actors last when you are surethey are not needed anymore

Green script:
nothing wrong here, but that depends where did you put it. Not all actors receive input, you eitherplace those input events in player controller or player pawn, or force recive input to your actor.
To check if you get any input connect print node right to events

The problem is you do the overlap in the coin. Every coin will have this once called and once increase it’s TotalCollected amount from 0 to 1 and then if you press 0 the first coin consumes input and prints out “1”.

You have to do the overlap in your character and have a TotalCollected there thats being increased.

Would a empty game object work or do i need to do in Character?

Can i do a Log of something like printf(“total = %d”,totalCollected)?

Not sure why an empty game object would be better. I’d just put the variable on my pawn or character. The coin BP would then update the variable on the pawn.
you can use append for your print string to build whatever you want. I’d guess you’d eventually want this on a widget though.