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 tanavya · Mar 01, 2017 at 07:18 AM · animation2d gamelinerendererlineaim

How to create an Animated 2D Line to help the user aim and shoot?

So I'm creating a bubble shooter-like-game, in which the user needs to shoot a bubble at some other bubbles, obviously ;p but like in normal bubble shooters, I need that animated line that can be seen when the user aims. Here's a screenshot of a bubble shooter game! alt text Now the special thing about this aim line is that it sort of pulsates. Those circles or dots grow larger then smaller in size repeatedly, though I don't know if it's clearly visible in the pic. Till now I've experimented with Unity's line renderer and created a texture with a small dot on it that I've tiled in a material. When I attach it to the line renderer it does (sort of) look similar to the one in the pic, and I'm sure I can make it look better. Still, I want it to create that sort of animation, but I've sort of given up now.. :/

Any help would be appreciated!

Thanks!


EDIT I was wondering if there was a way to do that in a script by filling the path between where user's mouse is, and the start point, with these circles that can be animated, but then the user needs to drag the mouse around and so the line should move with it while being anchored at one position.. I am not sure how to achieve that though.

screen-shot-2017-03-01-at-123945-pm.png (314.6 kB)
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
1
Best Answer

Answer by hexagonius · Mar 01, 2017 at 05:42 PM

I'd create a pool of animated sprites if it's a 2D game (scaling up and down, sort of). Since you know the start and the direction of the line, you just reposition them in intervals. I don't know what you do to reflect on the wall, math or Raycasts in combination with Vector2/3.Reflect, but that gives the path after hitting the wall. So:
- after each x steps place the bubble. - if x is too long for until it hits the wall, subtract the remaining distance and work along the reflected line with the rest of x and place more... - until you're satisfied with the length

If you do this depending on where it starts, which direction it goes and how long it is, the user should be able to just alter the direction and the algorithm places all dots to their new places.

Comment
Add comment · Show 2 · 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 tanavya · Mar 03, 2017 at 07:17 AM 0
Share

Seems like what I should do hm. How should I reposition them at intervals though? The interval length has to be constant I suppose, but how would I change the position? I'm guessing it'll be a combination of some math, like pythogoras theorem? :p Thanks for your reply though

avatar image hexagonius tanavya · Mar 03, 2017 at 07:23 PM 0
Share

it's easier than that. position + direction also is a position. So start + first portion of the direction vector is your first bubble, adding to it the same distance the second and so forth. it's basically a for loop to do that.

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

179 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 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

Unity Linerenderer jaggy lines 0 Answers

A line between two objects with conditions 0 Answers

2d game - animation - drinking/glass 1 Answer

I can't see my animated 2D character in "Scene view" 1 Answer

Can't get a smooth following line 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