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 /
avatar image
0
Question by jrpimentel · Apr 08, 2017 at 12:46 AM · 2d animationaiming2d rotationtop down shooter

Hotline miami style shooting controls from an angled top-down perspective?

I've hit a dead end and could use some help from those more experienced than me.

I'm making a top down 2D adventure/shooter game in a sci-fi setting. The graphic perspective is comparable to 2D Zelda games or Stardew Valley. However, for combat, the mechanic I'm trying to achieve is that you hold down a key (left shift in this case) and the cursor switches to a crosshair and you are able to rotate and shoot your gun Hotline Miami style. The obvious issue with this is that as HLM is actual top-down perspective, it's a relatively simple task to just have the character sprite rotate to the mouse position, but due to the Zelda-like perspective of my setting and character, this isn't an option.

My approach to making a solution to this while still maintaining the feel of how hotline miami's aiming/shooting works was to use math to create an imaginary X in the screen with the player being in the center where depending on which of the 4 sides of the X the mouse was in while the player was in combat mode, the sprite would change to facing that direction. Then I figured I would separate out the arms/gun from the sprite and put them as separate child objects of the player and edit the animations themselves to change to the correct sprite for each direction being faced. I figured I could then create a separate script specifically for the arm/gun child object that would make it rotate to face the cursor while the body of the sprite was limited to only the 4 cardinal directions through the X method mentioned above. In theory, I figured this could give the same smooth feeling of the HLM aiming system while still maintaining an angled perspective and limiting the main body of the sprite to only be facing 4 directions like how it is in Zelda.

I spent a good 6 hours refining this and positioning the child arm/gun objects perfectly so that they were in the perfect position for each frame of the simple character walking animation. I got to the point where it finally looked right and seamless and the arm/gun sprite would correctly change to the correct sprite and layer order in the animation depending on which direction the body was facing.

Where I'm getting stuck on is now trying to get the arm object to rotate to the crosshair cursor. It doesn't seem to be working out in the way I want. Since all the different facing arm sprites have different "up" or "forward" directions for their vector3s, using traditional rotating scripts to change the direction of the sprite facing towards the mouse cursor (similar to what would be used for a top down 2d space shooter) doesn't seem to work. I'm starting to dread that I've gone way far down a path that won't work for what I'm trying to accomplish.

Does anyone have any ideas on how to accomplish what I am trying to do with this game mechanic? I'm still kind of a novice when it comes to scripting in unity, so in all of your collective, more experienced opinions, am I going about this in the right way or is there an obviously better way to accomplish this that I am missing? I feel like I have dumped a ton of time and resources into getting this to work and I'm frustrated and discouraged that I've gotten this far and seem to have hit a dead end. Any ideas are helpful.

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How can I rotate an object towards a collision normal in 2D? 0 Answers

How to flip 2d character walk movement? 3 Answers

Problem with 2D gun rotation script (Would really apreaciate help) 1 Answer

Face target first then move forward to it - Top Down 2D 1 Answer

How to keep Diagonal Movement Direction in 2D Isometric game? 0 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