2D side scroller enemy Ai

I am creating a 2D side scroller plate-former and i am trying to make a Mario bros type enemy’s the ones that just go back and forth from point a to point b and die when jumped on. I need help in making the script like that and leaving out any interest in the player

There are several complete Youtube tutorials for making Mario Bros in Unity (I just looked).

Start from one of those. If you have problems, try this approach for posting here:

How to report a problem in the Unity3D forums

Many people struggle with properly reporting a problem on the Unity3D forums. This post is to try and help you get it right and speed up your return to success.

Step 1. Choose a good subject line. Don’t choose “Help!” or “Doesn’t work” Instead say “Need help with inventory system” or “Getting an X error when I pick up an item.”

Step 2. Do a little bit of basic research on your own. Double-click the actual error and try to see what code it relates to. Google the error text itself. Read at least two or three results. You will NEVER be the first person to have this error, trust me.

Step 3. Identify at least the ballpark area where the error is in your code. Extract the relevant section of code, as little as you think will show the problem, and post it here. If you don’t post code, we can’t help you. If you post massive amounts of code, we’ll assume you’re not even trying to be helpful. If nothing is happening, use Debug.Log() to find out if your code is even running.

Step 4. When you post code, use CODE tags (in square brackets) to format your code so we can read it. Do not retype your code; use copy / paste-match-style, otherwise you’ll introduce extra typos.

Step 5. Tell us the following things and be very precise.

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, log output, variable values, and especially any errors you see
  • links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)

The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?

If you post code, only post the relevant code and always use the format button above. Do not post photographs of code.

Remember, we are not here to do your work! You are going to do your work yourself, perhaps based on our answers to your questions. Therefore it is of critical importance that you ask the question well if you want useful answers.

Also if you are following a tutorial, none of us here are going to go and try out the tutorial to see where you have the problem. It falls on you to first understand it well enough to present your issue in terms of the above requirements, otherwise we simply are not going to be able to help you.

Don’t forget:

Two steps to tutorials and / or example code:

  1. do them perfectly, to the letter (zero typos, including punctuation and capitalization)
  2. stop and understand each step to understand what is going on.

If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning, essentially wasting your own time. It’s only two steps. Don’t skip either step.

Step #2 is particularly critical when learning.

If you are unwilling or unable to do Step #2, just ask someone else to do the whole game for you.