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 /
This question was closed Jan 17, 2016 at 05:01 PM by Fattie for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by Codelyy · Jan 17, 2016 at 04:39 AM · c#2dprogramming

Programming in 2d games

I'm trying to create a 2D game of my own and I'm strangely finding it a lot harder to do then a 3D game just because everything needs to be programmed unlike in 3D where you can use animation a lot. Of course this isn't a program but there a lot of stuff I find very difficult to program and would some stuff i wouldn't even have a clue on and I'm feeling as if I'm missing something when programming in 2D that makes it a lot easier then how I'm doing it.

What I would like someone to do is to be able to give me an idea on how to program something like this from a game: https://youtu.be/DR1J8IuA65c?t=1m49s (It starts at a certain part)

What I'm talking about is the multiple spikes that turn to face upwards and shoot upwards before being destroyed. I would have no idea on how to program something like that without a lot of timers counting down and even worse I wouldn't have any idea on how to make multiple of the same object next to each other all spawn at once.

Would anyone be able to give me a idea on how i would do something like that? I would be very grateful for the help

Comment
Add comment · Show 5
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 Internet Friend · Jan 17, 2016 at 05:00 AM 0
Share

Is there a problem with a lot of timers counting down? A single shared timer might be more efficient, but I wouldn't worry about that sort of thing before it's an actual problem.

$$anonymous$$aking multiples of the same object sounds like prefabs to me. Check out this doc page: http://docs.unity3d.com/$$anonymous$$anual/InstantiatingPrefabs.html

avatar image Codelyy Internet Friend · Jan 17, 2016 at 05:07 AM 0
Share

It more seems like I'm making my code a lot more complicated to do a simple function then it should be. I don't have a example to show sadly. Though i could be wrong and I'm doing it the way everyone does it XD

avatar image Codelyy Internet Friend · Jan 17, 2016 at 05:08 AM 0
Share

Plus if it's simply instantiating prefabs, then how does one do it about 7 times and have each object spawned next to each other?

avatar image Internet Friend Codelyy · Jan 17, 2016 at 05:44 AM 0
Share

The link I posted has example code specifically for instantiating prefabs in a row. It's in 3D, but it shouldn't be that hard to translate to 2D.

Yes, you will have to write a bunch of code to make a game, no two ways about it. Yes, being more knowledgeable and experienced will mean you'll need less code to make a game. No need to overthink things, just start throwing crap together and worry about aesthetics later.

avatar image corn · Jan 17, 2016 at 03:17 PM 0
Share

Well you could code a Spike$$anonymous$$anager or Trap$$anonymous$$anager that would spawn a spike every X seconds and "fire" it. The spikes' positions could be drawn randomly at runtime, or handpicked in advance. And if you want to use lots of spikes, the Object Pool Pattern would definitely come in handy (you only spawn N objects that you keep reusing afterwards).

If you lack experience in development, the best thing you can do is dive in. Think of a way to implement this, it probably won't be perfect, it might even totally fail, but just code it. Once it's done, try to understand what went wrong, what design flaws you could have avoided right at the beginning, what problems appeared afterwards as a consequence... Even if your code sucks and is not exploitable at all, if you analyze it and understand your mistakes, it won't have been a waste of time.

Also, you definitely have to look into design patterns. Countless people have had exactly the same problems you have/will be facing (not always in the same context), and many great solutions that will definitely come in handy have emerged.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

70 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

Related Questions

Android detection not detected by android phone 0 Answers

Function runs twice 0 Answers

Object with rigidbody2D doesn't move when it's supposed to, 0 Answers

Drag 2D Sprite by Touch 1 Answer

Move GameObject to Position, Waiting, and then Moving to Another Position 5 Answers


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