Hello, i am trying to learn blueprint, and I know i can just place my spikes mesh and add a “Pain Causing Volume” over it with a great value to kill my char. but in the spirrit of learning i want to do it with Blueprint, and create a “Prefab” i can just place in the map and it will work as intended.
So i just wonder how i would do this, ive added the mesh to the BluePrint and i suspect i gotha use the “OnComponent Hit”, and if i use Tags i can make sure only characters with speciall tags will be damaged by the asset.
I think i got the logic down, i just need a simple this is how and why. Since i get what it does, i just gotha see how.
when i get my feet wet i will on my own experiment try to trigger a special Death Animation when struck by it.
Simplest solution is to add a collision volume to your BP and override the OnHit event. Check if the actor that was touched is a valid Player/Charcter and kill him. You can make use of tags if you want. But most of the time you can simply cast the HitActor to a certain character class and if the cast succeeds, kill him.
And since i am totaly new, what does “Cast To Character” do, in how does it work, i might be asking hard, but ive been following Tutorials, but when i am done with alot of it, i dont understand “Why” it works, is there a good tutorial series that explains the nodes or is it a CheatSheet kinda thing that exlpains the functions behind the the nodes?
Are you familiar with the concepts of Object Oriented Programming (does not matter which language) ?
If yes, ‘casting’ means converting an object of one class (or blueprint) to a derived class.
For instance lets say you have a BP named MyActor which is based on Actor. Now if you create an object(instance) of MyActor BP (lets call it MyInst) it is both an Actor and a MyActor at the same time.
Now suppose your spike hit MyInst, the Actor object passed to the OnHit event will be an instance of ‘Actor’ - not MyActor. So you if you want to check and make sure the actor your spike hit is an instance of MyActor, you will try to cast the given object to MyActor - if it succeeds, it means the spike hit an instance of MyActor, if it fails, it means your spike hit some other type of Actor.
This is a quite vast subject and I suppose you need to go through the video tutorials posted in youtube (by Zack Parish). He explains these concepts in detail and in an easy to understand way
Start with number 27: 4-Creating a Class Blueprint
Thanks alot for the help sir, ive been doing some experimenting on my own, just to see how far i get from playing around with BluePrints, and i got the spikes working, BUT, it wont “kill” my char in one hit, it just takes all the health, then i gotha “jump” on it again to die, here is my Blueprint, where am I messing up?:
Ive also tried to create a Gas blueprint that kills slowly when standing in the collison cube, but when using “Tick” it goes by to fast, and tried to connect a “Seconds” node to the Deltaseconds point, but to no luck, i am REALY new at this and only learning, so dont be too harsh
About instant kill:
Try adding a damage that is a lot more than the max health. For instance if your max health is 100, apply a damage of 500.
Now if you need to play some death animation, you can override the TakeDamage event in Pawn and do that there (when health goes below 0). After that simply UnPosses the pawn or even destroy (by calling Destroy() node) it as needed.
About Gas volume:
Your graph seems to be wrong.
But before going into that, take a look at PainVolume which is built into the engine. You can put one of those in your level and set it parameters and it will automatically apply DOT (damage over time) to actors that goes inside the volume. But you will need to implement the Damage related events in your Pawn to play the right animation…
Thanks for helping, for the first time i am feeling i am getting anywhere, and its alot thanks to you, but i raised the damage in my spike blueprint to 1000 just to overdo it, but i still get the same problem, this is my current health system on my Char, just incase ive done some mistakes there that ripples trough my entire setup
Do the Health <= 0 check right after/before setting the new health. In the present setup, even if your health goes below 0, it wont detect it until the next time.