Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to create auto kicking enemy objects?

In this case, I am making Level 4 of my new game set in a dark atmosphere. With half the road left to be filled with obstacles I intend to take things to the next level.

My idea is to create a bench (which I have a Prefab of) and a human character sitting on it (which I need help with).

The human character will serve as an obstacle or enemy object whose either leg will be visible or in the way of the road.

If the ball approaches too close, the human would simply kick it away creating a force for that second or two.

This probably requires some OnTrigger Event which I really need help with, being a beginner to C# code and everything.

(Yes, in C# format), alongside the steps of how to reference the player object.


Comments

  • edited May 23

    Make a box collider trigger that fits how far away you want to kick. Then, add an animator and a kick animation . Add a animator parameter trigger called Kick. Create a C# script called KickingEnemy.cs:

    using UnityEngine;

    public class KickingEnemy : MonoBehaviour

    {

    public Animator animator;

    void OnTriggerEnter ()

    {

    animator.SetTrigger("Kick");

    }

    }


    and the box collider trigger has to be on the enemy

  • CattyCatty Member

    I played your game and it's really great. There's just a little problem when I touch the black line that limits the width of the level field, it just slows me down so much that I can stop and the level is not repeated. ❤️

  • Alex4791Alex4791 Member

    I really appreciate your support towards my game, Catty. Maybe you could explain the little problem more? I get the slowing down part, without which some players might give up on the abundance of difficulty from level to level.

  • Alex4791Alex4791 Member

    Thanks, Dreek16designer. Since there's no video, I might consider creating a copy of my project just so things don't mess up.

    For starters, I tend to do something and close without saving if it messes up my game. But C# code has to be saved in order to work. Sometimes even by deleting newly created components do I find no way to revert into my original settings.

    Might stick to the backup project method, for now and a while.

Sign In or Register to comment.