Uploaded August 2021 | Updated September 2026, 3 weeks ago
#unityenemy #unityjumponenemy #unitystompenemy
In this video I show you a simple way to stomp enemies jumping on their heads.
I play games here - twitch.tv/zzotoff
You are very welcome :-)
Thank you :-)
Project Files Here drive.google.com/file/d/1_xKBgksGtamkIj3G7XKc5dCVt4kGnSGO/view?usp=sharing
I start from an empty project as usual. First game object here will be the ground. Ground needs a collider so the player could walk on it. Edit it a bit. Next game object is a player which is a kind of boot. Scale it down a bit. Boot needs a collider to walk on the ground. It is a circle collider. Edit it like so. Next component is a rigid body 2d which helps to move my boot and detect collisions. I set gravity scale to 3 to make the boot fall faster. Set collision detection to continuous for more precise collision detection. And freeze Z rotation to prevent my boot from rolling over. Boot will have a script. Here it is. Script helps me to move my boot left and right and to make it jump. Script goes to boot. Right click on boot and create a new empty child. This game object will detect enemies' heads. Head check needs a collider for that. It will be a trigger. I edit it so it’s positioned right at the bottom of my boot and under that circle collider. Head check will have a script. Here it is. Script has an access to boots rigid body component for the purpose to create that little bouncy effect when the enemy is stomped. Script goes to enemy head check. Select head check and D&D bot game object to boot rigidbody slot. Right click on boot and create another empty child. This game object will be checking if boot collides with enemies body. Enemy check will have a couple of colliders which will be triggers. I edit them like so. Enemy check will have a script. Here it is. So when enemy check collides with an enemy the boot is destroyed. Script goes to enemy check game object. Boot is done. Next game object is the enemy. Scale it down. Put it here. Enemy will have a collider. Set it as a trigger. This collider represents enemies body. So the boot dies if it touches it. To make it work, the enemy will have a script that is just an empty one and it helps Enemy check game object to recognize an enemy. Script goes to enemy. Right click on enemy and create new empty child. This game object represents enemies head. It will have a collider. Set it as a trigger. Edit it so it positioned right above bodies collider. Like that. This game object will have a script. Here it is. So when this game object collides with enemy head check game object attached to the boot enemy is destroyed. This script goes to Boot check game object. Now I can hit play and see how it works. So if boot jumps on enemy then enemy is destroyed. And if boot touches enemies body then boot is destroyed.
#unityenemy #unityjumponenemy #unitystompenemy
In this video I show you a simple way to stomp enemies jumping on their heads.
I play games here - twitch.tv/zzotoff
You are very welcome :-)
Thank you :-)
Project Files Here drive.google.com/file/d/1_xKBgksGtamkIj3G7XKc5dCVt4kGnSGO/view?usp=sharing
I start from an empty project as usual. First game object here will be the ground. Ground needs a collider so the player could walk on it. Edit it a bit. Next game object is a player which is a kind of boot. Scale it down a bit. Boot needs a collider to walk on the ground. It is a circle collider. Edit it like so. Next component is a rigid body 2d which helps to move my boot and detect collisions. I set gravity scale to 3 to make the boot fall faster. Set collision detection to continuous for more precise collision detection. And freeze Z rotation to prevent my boot from rolling over. Boot will have a script. Here it is. Script helps me to move my boot left and right and to make it jump. Script goes to boot. Right click on boot and create a new empty child. This game object will detect enemies' heads. Head check needs a collider for that. It will be a trigger. I edit it so it’s positioned right at the bottom of my boot and under that circle collider. Head check will have a script. Here it is. Script has an access to boots rigid body component for the purpose to create that little bouncy effect when the enemy is stomped. Script goes to enemy head check. Select head check and D&D bot game object to boot rigidbody slot. Right click on boot and create another empty child. This game object will be checking if boot collides with enemies body. Enemy check will have a couple of colliders which will be triggers. I edit them like so. Enemy check will have a script. Here it is. So when enemy check collides with an enemy the boot is destroyed. Script goes to enemy check game object. Boot is done. Next game object is the enemy. Scale it down. Put it here. Enemy will have a collider. Set it as a trigger. This collider represents enemies body. So the boot dies if it touches it. To make it work, the enemy will have a script that is just an empty one and it helps Enemy check game object to recognize an enemy. Script goes to enemy. Right click on enemy and create new empty child. This game object represents enemies head. It will have a collider. Set it as a trigger. Edit it so it positioned right above bodies collider. Like that. This game object will have a script. Here it is. So when this game object collides with enemy head check game object attached to the boot enemy is destroyed. This script goes to Boot check game object. Now I can hit play and see how it works. So if boot jumps on enemy then enemy is destroyed. And if boot touches enemies body then boot is destroyed.










