Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by hunnumun · Feb 16, 2017 at 10:00 AM · unity 52d gameenemy ai

Galaga-type enemy AI

Hey unity community, this is my first time posting so do tell me if i break any etiquette.

Now on to my question, im currently practicing coding in C# to teach it to myself. I do this through creating a galaga-type game (top down, 2d, powerups bullets, space etc.).

i have my playercontroller working and all and im starting on the enemy ai. thing is im fully stuck as i cant find anything related to putting 2d enemy objects into a grid, and even less on having them enter a level with a set path. is there any way some of you can help me? or point me in the right direction?

i myself was thinking about using a table, or an array of gameobjects that act as "idle positions" for the enemies to fly to when done "entering" the level. but i would have to check if a gameobject is already taken or not. anyhow, any help is appreciated!.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by arjanwiegel · Feb 16, 2017 at 12:40 PM

If you're new to programming try not to program the movement, but make a simple animation in the animator and trigger that in an animation.

There is really not much AI to Galaga. Everything is a scripted animation that does not respond to your actions except for the direction of the bullets maybe.

Adding simple animations to individual enemies could make them do "real" attacks.

Why don't you first place the enemies by hand for a start, like space-invaders and parent the "wave" to a common gameobject that moves from side to side and down slowly. (animation). The then only needs to change the sprites, so it looks like it is animating, die when a bullet hits it and sometimes drop a bullet down. You could make multiple waves or simply increase the speed of a single repeating wave.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hunnumun · Feb 16, 2017 at 01:21 PM 0
Share

thanks for this tip, i will try this first. the space invaders type roster by childing the enemies and animating the parent object is a smart train of thought.

i did try animating individual enemies but every time i instantiate that prefab the animation gets called at the 0x 0y 0z axis relative to the worldspace. if i can find out how i can put that relative to the parent's axis then im all set.

still thanks bunches!

avatar image arjanwiegel hunnumun · Feb 16, 2017 at 01:36 PM 0
Share

To animate a gameobject relative to another transform make a prefab which is the enamy and give it a child that has the animation. That way you can place the enemy anywhere you want and animate its child from there.

avatar image hunnumun arjanwiegel · Feb 16, 2017 at 01:50 PM 0
Share

thats so smart, cant believe i hadn't thought of that! thanks!

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

139 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Object movement algorithm 0 Answers

Destroy a game object after holding Mouse 0 for some time 1 Answer

How to rotate a 2d object with joystick in unity ? 0 Answers

How do I create a 2D Seamless World Map? 1 Answer

My enemy is going the wrong way 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges