# deltaweb

Member

10

127 Neutral

• Rank
Member
1. ## How to create a circular orbit and an angry bird space like orbit ?

Oh, so angry birds didn't use real life physics ! , In my game i would like it to be as realist as possible .   Thank's on your explantion .
2. ## How to create a circular orbit and an angry bird space like orbit ?

Your answer seem logic, but when i read this article, I become confused : http://www.wired.com/2012/03/the-gravitational-force-in-angry-birds-space/   There is a part about friction, where the physician here think it's a constant force, and it seem true from his test .   So what do you think ?
3. ## How to create a circular orbit and an angry bird space like orbit ?

Also one more question : for the angry birds like orbital decay, should the drag be constant or it should be dependent on how my gameobject is from the planet ? : closer to the planet---> higher drag value ?   the physics engine i'am using take care of air drag calculation, i just have to set a value from the editor or from script ...   Also does the velocity of the gameobject affect the drag value ?
4. ## How to create a circular orbit and an angry bird space like orbit ?

Well i think that it's working, because the physics engine take care of all the other stuff, like the time step .
5. ## How to create a circular orbit and an angry bird space like orbit ?

I've solved the issue : my perpendicular vector was (dist.x,-dist.y) where it should be (-dist.y, dist.x), more here : http://stackoverflow.com/questions/29704731/circular-orbit-formula-is-not-working-in-unity-3d/29704896#29704896
6. ## How to create a circular orbit and an angry bird space like orbit ?

Okay, here's the full code that i'am using to implement the circular orbit from the physics side : using UnityEngine; using System.Collections; public class Orbit : MonoBehaviour { Vector2 dist = new Vector2 (); Vector2 tdist; float r; float mBody; float mPlanet; public GameObject Planet; public float G; void Start () { mPlanet = Planet.rigidbody2D.mass; mBody = rigidbody2D.mass; } void FixedUpdate () { circularOrbit(); } void applyGravity(){ dist = new Vector2 (Planet.renderer.bounds.center.x - renderer.bounds.center.x, Planet.renderer.bounds.center.y - renderer.bounds.center.y); r = dist.magnitude; float force = G * mPlanet * mBody / (r * r); rigidbody2D.AddForce (dist.normalized * force); } void circularOrbit(){ // Get the distance between the two object centers . dist = new Vector2 (Planet.renderer.bounds.center.x - renderer.bounds.center.x, Planet.renderer.bounds.center.y - renderer.bounds.center.y); r = dist.magnitude; tdist = new Vector2 (dist.x, -dist.y).normalized; // 2D vector prependicular to the dist vector . float force = Mathf.Sqrt (G * ((mBody + mPlanet) / r)); // Calculate the velocity . rigidbody2D.velocity = tdist * force; } } The important part is in the circular Orbit function, and here is a small gif of what's hapenning :    http://makeagif.com/i/-JxBG8   As you can see the monster is not orbited by the planet, here are some infos :   Monster mass : 1 unit; Planet mass : 5 unit ; Gravity of the monster is off ; G is 1, but the probleme stay the same for all value that i've tested : 0.1 , 0.01 , 1 , 5 , 20.... All i want to do is to be able to make the monster get in a circular orbit, for the angry bird part, this is a whole another story, that i will work on once i get the circular orbit working .
7. ## How to create a circular orbit and an angry bird space like orbit ?

Oh, thank's for everyone who answered, i've found a way to do that by playing with rotation and gameobjects, For anyone who would like to know how i did it : Create an empty gameobject and set it postions to the planet pos make your orbited gameobject a child of this empty object . Rotate the empty game object with a Z angle ( 2D way ) . This can only be done using unity. Once again thank's for everyone, i've learned a lot .
8. ## How to create a circular orbit and an angry bird space like orbit ?

I've tried what everyone said to get a circular orbit, but the gameobject is still going too far to the left while the planet is in the right, I don't know why ?
9. ## How to create a circular orbit and an angry bird space like orbit ?

Thank's for every one on their answers, actually i've forgot to apply a vector prependicular to dist vector, But when i did that, i got another problem :   The orbiting body is going to far while moving in a circular way, but i don't know why , here's my code again : dist = new Vector2 (Planet.renderer.bounds.center.x - renderer.bounds.center.x, Planet.renderer.bounds.center.y - renderer.bounds.center.y).normalized; r = dist.magnitude; Vector2 t = new Vector2 (-dist.x,dist.y); float f = Mathf.Sqrt ((5.00f * (mPlanet + mBody)) / r); rigidbody2D.velocity = t * f ; Dist is the normalized distance vector, t is the prependicular vector to the dist one, f is the velocity which is calculated from wikipedia : http://en.wikipedia.org/wiki/Circular_orbit#Velocity   Please tell me where i'am wrong ?   thank's
10. ## How to create a circular orbit and an angry bird space like orbit ?

I am working on a 2D game, and I am working on adding some space physics : I need to find a way to create a circular orbit and an orbit like angry birds space ( the spiral trajectory ) . So there is 2 question    First Porblem :   I want to create a circular orbit, to make my game object move on a circular way around a planet, I am using the old famous formula :            This formula is the classic real world one, V is the velocity of the game object .   Once i code it, it doesn't move on a circular way, it just being attracted by the planet, like normal gravity . Here's my code (i'am using Unity 3D ) :        dist = new Vector2 (Planet.renderer.bounds.center.x - renderer.bounds.center.x, Planet.renderer.bounds.center.y - renderer.bounds.center.y); r = dist.magnitude;        rigidbody2D.velocity = dist.normalized * (Mathf.Sqrt (0.5f * ((mBody + mPlanet) / r))); Dist is a 2D vector and r is a float, The G value is 0.5 ( I used this one because 6.673E-11 is very small and it's not what i want )   So the question is is how can i make my gameobject move on a circular orbit like a satellite around earth ?   One thing to note, is that my gameobject is kicked by the player, so it get a speed of 12 . (i am using addForce() ) .     2nd problem :   I want also to be able to make the gameObject to be attracted by the planet in the same way of angry birds space or something like that, i need it to be attracted in a spiral way, which i can't find any ressource on the web to do that . I am using a simple code that use the Famous Gravitional law of Newton :         dist = new Vector2 (Planet.renderer.bounds.center.x - renderer.bounds.center.x, Planet.renderer.bounds.center.y - renderer.bounds.center.y); r = dist.magnitude; float force =  0.5f * mPlanet * mBody / (r * r); rigidbody2D.AddForce (dist.normalized * force); 0.5 is the value of G, Actually this is a port of a code in C++ that'ive found on a BOX2D forum . This work very well with attracting object, but what i want is that the gameObject follow an angry birds space like trajectory once it enter the gravity field of the planet :      So how can achieve a similar effect ?   Please explain in beginner friendly way if you answer , I don't have advanced physics  and math knowledge (I am only a high school student ) .   Thank's !