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 2020

    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. ❤️

  • 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.

  • 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.

  • Hi, @Catty. You once responded after playing my trial game last year appreciating how great it was. This optimism by you and several others really stuck with me as I went on to making the full 10 level game with whatever free time there was.

    Hope you're doing great. I am delighted to share the full version with you now a year later. Hope you enjoy it just as much as the trial. Your feedback would mean a great deal of information, but that's your call. Thanks. :)

    The WebGL version to the full game gets laggy on Level 7 and further on. The Windows downloadable version does just fine.

    Ball Sprinter 3D: Night Shift (The Complete Edition) - Unity Play

    https://www.dropbox.com/sh/gklgs2ev5xaltwc/AAAhesAHaU-fkLaA83ypNi5ya?dl=0

Sign In or Register to comment.