Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by pdunton · Jul 01, 2014 at 08:23 PM · javascriptvelocitygravitypath

Angry Birds Space like Object Path Model

In the popular game Angry Birds Space there is a feature that allows you to see where your bird will fly while taking in gravity and updates in the angle you have your slingshot. I have a game where the player can create planets and suns, change their size, and give them an initial velocity. The only thing this is missing is this path system that I want to be almost exactly like Angry Birds Space. Ive tried creating an empty object with a trail renderer that has the same mass as the planet (keep in mind that the path of the planet does depend on the mass of it), a Gravity script, and the same initial velocity as the slingshot will give the planet once launched. This works ok, but once the empty object is launched, there is no way to update the path by changing the angle of the slingshot, and the trail length is not constant. I will post screenshots of the slingshot(its more of a radial slingshot with a disc), and of Angry Birds Space. Any ideas? Thanks!

Angry Birds Space

SlingShot

untitled.png (46.7 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
0

Answer by fafase · Jul 02, 2014 at 12:07 AM

Considering you are in space, there is no general gravity, I mean that the projectile goes straight if there is no planet item on your scene.

Then it is fairly easy to draw that situation, just take the direction vector and draw a dot every x unit.

Now, you want to modify that dot position if there is a gravity field nearby. Well the process for the dots is the same as for the projectile itself. If you are far enough from all planets, nothing happens, if you are close enough to one or more planets, add up all gravity forces to get the final force and add it up to the position of your dot.

As pseudo code:

 foreach dot
     foreach planet
         Vector3 force = Vector3.zero;
         float dist = distance(planet, dot);
         if (dist > planet.range) continue;
         // linear attenuation, you may use square if you feel like (more realistic) 
         force += 1 / dist * planet.initialForce; 
  
     dot.position += force;

So pretty much, iterate through all planets, if too far, ignore, else consider the distance to the center (full force) and attenuate the force based on that distance. Add all forces and move the dot with that final force.

Comment
Add comment · 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

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

21 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

Related Questions

How to set velocity of Rigidbody without changing gravity? 1 Answer

How to get an Object to move physically correct (velocity) 1 Answer

How to make a Block chek if it´s floating? 1 Answer

Particular "Jump" Script. 2 Answers

Room Path Generator 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