I created this blueprint called "SpecialItem_BP" for our game. It is composed by a static mesh, which I added a ring mesh to it, and a collision box. So, my objective was to create an object that floats in the air and rotate in the Z axis. Also, I added a counter to it. So every time that you pickup a ring it will add one in the counter and we will use this counter in our inventory system for this item and other ones.
Here you have a screen-shot of the blueprint:
I created a function to rotate the ring and I linked it with the Event Tick, so the object will rotate indefinitely. Thus, I modified the "delta rotation" in the Z axis to 5.0. So, it will rotate with this velocity.
I also add an event "OnComponentBeginOverlap" to make the interaction between the character and object (ring). I created a variable "counter" in the main character blueprint, to store the value of the counter. After that, I linked a cast to the event "OnComponentBeginOverlap" and I linked it to a function "toggle visibility" to capture the object when you get close. Finally, I just made the counter be incremented by one and I printed the value on the screen, so we can see that the counter is being incremented.
Here are some screen-shots of the game working.
I add a lot of the objects into the game to see how it works and to test the counter. You can see that the rings are rotating in the Z axis as expected.
Here you can the see the counter being incremented when the character pickup a ring.
So, we can use this blueprint with different kinds of objects. We just need to change the mesh, to have a other type of special item to our game.
No comments:
Post a Comment