Honestly this is the best tutorial about this topic
@garcia79532 жыл бұрын
Why is your channel so small? Great content! You deserve so many subscribers, i can understand something so complex in just some minutes, that is amazing! Congratulations.
@coderious45682 жыл бұрын
Thank you so much it means a lot!
@StellarMirage3 жыл бұрын
I knew the formuals and everything but wasn’t ready to implement it but after seeing your video I got the faith in myself to implement it and now I have my own solar system.
@coderious45683 жыл бұрын
congrats!
@t2g4_channel Жыл бұрын
Whoah, this is awesome! Thank you! Super video, it is short, explaining a lot, and have clear demostration!
@LordxGx07 Жыл бұрын
A beautiful simulation with physics formula on Unity, beautiful ! I'll reproduce your code I guess. And after that, I'd like to add code to simulate planetary rings (or proto-solar disc, or accretion discs), like Saturne, Jupiter...
@ytubeanon3 жыл бұрын
quick tip - I think if you press Shift+F it will lock on to your selected gameobject in Scene view, so you don't have to manually scroll the screen with your mouse
@coderious45683 жыл бұрын
Excellent, thank you for the tip!
@Enderia2 Жыл бұрын
@@coderious4568t’s actually just f
@williamwall17852 жыл бұрын
Cool stuff! However, there is an error in the formula for velocity in an elliptical orbit. The (2/r + 1/a) should be (2/r - 1/a). Also, on the distance scale chosen, the earth and the sun would be fifty times smaller.
@coderious45682 жыл бұрын
Spotted it too, I've pinned a comment with the correction.
@rohithkumar2576 Жыл бұрын
Is there any way to download the assets directly? Someone please reply
@coderious45683 жыл бұрын
There is an error in the slide at 3:46, the elliptic orbit speed is the square root of G * m2 * (2/r - 1/a) where a is for the alpha in the formula. It is the length of the semi-major axis of the elliptical orbit (not a the game object).
@misa82863 жыл бұрын
This doesn't work for me this fix. it says "Operator '/' cannot be applied to operands of type 'int' and 'GameObject'" how do i fix this? and can i contact you?
@coderious45683 жыл бұрын
@@misa8286 there a link to Discord in the channel description, feel free to contact me over there
@bensawiuk70942 жыл бұрын
@@coderious4568 im having the same problem, where do i contact you
@coderious45682 жыл бұрын
@@bensawiuk7094 There is a Discord link on my page description
@coderious45682 жыл бұрын
@@misa8286 I added a clarification. "a" is the for the Greek letter alpha in the formula, not for GameObject a from the foreach loop. The alpha is the semimajor axis of its orbit.
@HaveDraw Жыл бұрын
What if i dont have the transform.right, how could i do the same thing?
@coderious4568 Жыл бұрын
How could you not have transform.right? All GameObjects have a transform.
@tntram28342 жыл бұрын
Very useful video! It would be interesting to see what could be done from this project
@smoothblock70092 жыл бұрын
hi , nice video but i have a question - when using urp my textures dont apply to my object. any solution please??
@ComplexKangaroo Жыл бұрын
Excellent tutorial, thanks! I got it working in Unity 2021.3.24f1 but my code is identical to yours and all the RigidBody mass settings and I turned off "use gravity" as you did, but the Earth takes off on a long comet like orbit. I had to multiply the initial velocity by 0.7 to get a perfect circle, which is weird. I just realized 0.7 is 1/sqrt(2), and indeed adding 2*r solved it and makes it work, but your code didn't have that and your code matches Wikipedia. Weird. Thanks for all the other cool tricks with TrailRenderer and speeding up project time.
@thedarkshadoww97112 жыл бұрын
Ty so much for the tutorial, helps a lot
@havendewart2 жыл бұрын
Just wondering why did you add two foreach loops. I am sure there is a good reason, but I just cant figure it out and I am trying to learn C# so was curious.
@gilleswalther59642 жыл бұрын
Because gravity goes both ways, A is "attracted" by B and B is "attracted" by A. With the double loop both ways can be captured.
@havendewart2 жыл бұрын
Thanks!
@divac30422 жыл бұрын
It's so cool! Thank you very much!
@Maxvellua2 жыл бұрын
Thank you for the video!
@ouuuaburger2093 Жыл бұрын
Do you think blender is better than Unity in rendering solar system?
@brotkrumeleintopf7749 Жыл бұрын
5:07 but your sun is moving away from the center?!
@taxtherich194 Жыл бұрын
thank you for this great tutorial.. merci
@tracksuitcheems2 жыл бұрын
Greetings. I followed your tutorial for the shader graph star and this one for the orbits. However, my planets are not dynamically lit. Could you do a video on lighting in Unity or recommend any good ones. Soulcraft looks good, btw. Hope to see it released soon. Thanks.
@Avariths3 жыл бұрын
So I have a weird problem with the velocity. When I add the velocity part to the script my earth just flies away. I copied the script line for line. Any idea why this is happening to me?
@coderious45683 жыл бұрын
Did you add mass to the sun?
@Avariths3 жыл бұрын
@@coderious4568 yes. I put the mass of the sun at 333000 and the earth at 1. Gravity of both planets turned off
@coderious45683 жыл бұрын
@@Avariths Did you add the tag to the celestials?
@Avariths3 жыл бұрын
@@coderious4568 I gave the tag Celestial to the sun and Earth. The gravity part of the script functions as intended. The sun also starts to move away from the Earth when the velocity component is added along with the earth shooting away
@bennettpoh2 жыл бұрын
Did you apply the script to the planet itself? If so, you have to create an empty GameObject and assign the script there.
@patrudoizero10 ай бұрын
I`m trying to create a deformable 3D space time grid in unity. How should I approach it?
@pikachuiswatchingu6012 жыл бұрын
hi this was a wonderful tutorial but im having a problem where after i added more planets the sun started to wander. like it wanders in a straight line and pretty fast too. i get that it gets pulled a little by the other planets but it's literally wandering to a whole nother galaxy
@coderious45682 жыл бұрын
Checking the IsKinematic checkbox in the sun Rigidbody will not apply physics on the object.
@mukapochotordo6492 жыл бұрын
Hi, could you make a tutorial to make the orbit in the shape of an ellipse? Very good tutorial by the way.
@coderious45682 жыл бұрын
The the formula for an ellipse is pinned in the comments. Thanks 👍
@mukapochotordo6492 жыл бұрын
@@coderious4568 ty so much!
@liliansananikone3588 Жыл бұрын
In realtime, is the G float member different for each celestial ?
@liliansananikone3588 Жыл бұрын
I did the same way with all celestials of your spreadsheet but some celestials end to collide (Sun, Mercury and Earth).
@tamargamer4667 Жыл бұрын
Where can i find a 3d models like These planets and the sun are wonderful
@coderious4568 Жыл бұрын
Thanks, I made a tutorial on how to create the Sun. Planet textures can be found on the NASA website and are public domain.
@snipeax04782 жыл бұрын
thank you, that helped me so much to figure some problem with my project, would it be possible to make a video on how to predict the trajectory of a planet with a linerender or something?
@JakubKas2 жыл бұрын
I get " operator '.' cannot be applied to operand of type 'void' " error message :/
@CheesyMez3 ай бұрын
thanks for such a good tutorial! would you know how to have the trajectory of an object ahead of time, rather than trailing behind the objects like in kerbal space program for example.
@overangelixvod1406 Жыл бұрын
Hello, I want to make a solar System but I understant why do you increased the earth mass by 15 ?
@coderious4568 Жыл бұрын
It's to make it work with the scale of the planet. To make it look better the distance and sizes of the planets are modified, so the mass needs to be adjusted as well.
@hue70752 жыл бұрын
Awesome stuff, how can I make the planet movements significantly slower but still make it work? new to coding sorry lol
@coderious45682 жыл бұрын
The speed can be adjusted with the G variable.
@TheRunningSongs3 жыл бұрын
I followed the gravity script but when i compile the script i get two errors saying ';' and '{' I double checked everything and nothing is working
@coderious45683 жыл бұрын
What code editor do you use?
@TheRunningSongs3 жыл бұрын
@@coderious4568 Visual code studio, same as you
@coderious45683 жыл бұрын
@@TheRunningSongs You can reach out on the Discord channel and post your code. There is a link to the Discord on the description of my page.
@TheRunningSongs3 жыл бұрын
@@coderious4568 Hello, Thanks fir the response, when i jooin the discord server it says invite invalid. If you could update the invite that would be great, thanks :)
@coderious45683 жыл бұрын
@@TheRunningSongs discord.gg/KsgpVVYcj9 updated
@myfishisnothappy15952 жыл бұрын
could you project shadows and add a fixed pov from earth surface? Even without earth rotation on its axis, to see the Moon phases? That would be amazing...
@coderious45682 жыл бұрын
Add a point light to your sun and it will cast shadows. URP does not support real-time shadow from point lights, but HDRP does.
@jeronimocollares3202 жыл бұрын
Nice tutorial, really thanks. But you have something about a 'HUGE' system star, Solar or, at last, what is the best way to do it without broke the engine (because this size of a space, planets, etc)?
@coderious45682 жыл бұрын
Hi, thanks for your comment. To make a huge system I would look into Compute Shader and ECS/DOTS. The two options are completely different but both allow to perform a ton of operations per second. I made a tutorial on how to use the compute shader, it might be suitable for what you have in mind. With ECS/DOTS Unity can manage thousands of different objects at the same time with much better performance than using the GameObject/Monobehavior framework. it is still a preview package though.
@jeronimocollares3202 жыл бұрын
@@coderious4568 Thanks for answering. I'm working with a 'middle ground' on the 'huge' theme. Instead of thinking in terms of 'huge', use tricks like scaling something down to avoid rendering and performance issues. There will be many steps, I'm still a novice - I know nothing about DOTS, I would like ideas, even. Now I focus on movement, like having a spacecraft, for example, flying in 'cruise flight' with this spacecraft being small and simulating that flight as something very slow and maintaining a good 'frame by frame' quality? That's my challenge, learn that. A smaller Universe, with small objects, pretending to be big. Another thing I've been looking for is light, like a general lens flare in this universe and combine it with this Sun used in your example. I know it's newbie stuff, I apologize - but that's how we learn. :)
@coderious45682 жыл бұрын
@@jeronimocollares320 To render big lands, procedural generation could help as well. I made a video about it. The concept is in 2D, but it's totally applicable to 3D as well.
@jeronimocollares3202 жыл бұрын
@@coderious4568 my idea is simple (as a new) its a space game using point and click - literally, like Eve Online in your BASIC aspect (for now, strict to two goals. Size of a sector in the Universe (objects included) and movement (here it goes from the movement of objects navigating in a three-dimensional space to that of the camera).
@sujalvc3 жыл бұрын
Nice video. Is deformation of planet w.r.t the nearest Celestial possible? Like if a planet goes near the sun, it will deform and vapourise.
@coderious45683 жыл бұрын
It should be possible in combination with the particle system.
@Baconmaster-ls4wf8 ай бұрын
Anyone able to help I have implemented this but the planets do not revolve around the sun they just start going all over the place
@coderious45688 ай бұрын
The project is available on GitHub link under the video if you want to compare your solution to the example.
@choc37322 жыл бұрын
Hey man, I have gotten it to work with the circular orbit! However for the elliptical it's not working. Seeing as this solar system is scaled down, what values do I need to use for the values: 2, 1, a in this part of the equation -> (2/r - 1/a)?
@coderious45682 жыл бұрын
r = distance between orbiting bodies a = length of the semi major axis
@choc37322 жыл бұрын
@@coderious4568 Thanks man. Do you know what factor I have to scale down the “a” value by? The actual value for a is about 100,000,000km. I’m not sure how to scale it down to suit this smaller solar system.
@R2_Audio_2 жыл бұрын
hi! this is a awesome tutorial, im making my own solar system simulation too, can i get the codes and the mass tables from somewhere?
@coderious45682 жыл бұрын
Masses and distances can be found on google quite easily
@JohananStarGiver10 ай бұрын
How did you make that beatifull sun? i cant find a way to make it this beatifull :(
@Keith-8h1a2b9i2 ай бұрын
is this used only for circular orbits, or can it make elliptical too?
@gilleswalther59642 ай бұрын
Works with elliptical orbits
@baskanaqua2 жыл бұрын
ur code working so good uhm how can i ask.. can i use this my education project?
@coderious45682 жыл бұрын
Yes you can use it
@baskanaqua2 жыл бұрын
@@coderious4568 i need to thank u!!! SO SOOO thank u so muchh ur so good
@Gaisiran4 ай бұрын
Excellent!
@alvaropazmino672 Жыл бұрын
WOWOWOWOW!
@mjc77472 жыл бұрын
Thank you soooo much!!
@damarkuncoro Жыл бұрын
i love it
@yaxalo2 жыл бұрын
I dont know if this is just me but my planets like to go out of orbit and shoot off into space.
@coderious45682 жыл бұрын
The script must be attached to one GameObject in the project not all planets. That might be the cause.
@R2_Audio_2 жыл бұрын
@@coderious4568 hi, i have the same issue can you help?
@DrDandD2 жыл бұрын
@@R2_Audio_ have you tried what Coderious said above.
@cfg45222 жыл бұрын
Make sure that InitialVelocity function is being called in the Start method and not in FixedUpdate
@chiefynuts Жыл бұрын
@@coderious4568 works perfectly. was confused for so long.thank you!
@abdelrahmanqe-55389 ай бұрын
Very Useful Vid
@fatimaarif59442 жыл бұрын
thanks life saver. < 3
@thegamedevstudent2 жыл бұрын
instead of the planet moving towards the sun, the sun is moving towards the planet in the gravity part. cud u pls lend a hand
@coderious45682 жыл бұрын
Have you double checked the mass of your objects?
@thegamedevstudent2 жыл бұрын
@@coderious4568 yes, the sun has mass of 333000 while the planet has mass of 1, still the problem is occurring
@coderious45682 жыл бұрын
@@thegamedevstudent double check the inputs, make sure gravity is off the rigibodies, that it is not kinematic and that the Celestial tag was added. Then use the debugger to check what is wrong :-) Good luck
@RiversJ2 жыл бұрын
Err i don't mean to be pedantic but i don't see Unity Physics being used here and i'm presuming this is using the built-in Physx physics engine?
@KassidyJMoore Жыл бұрын
I can't get the moon to orbit the planet
@myfishisnothappy15952 жыл бұрын
I luv you.
@sanyohamarr8285 Жыл бұрын
As expected, it doesn't work. Oh well, another tutorial fail.
@Brainyplanet Жыл бұрын
It worked for me, maybe you missed something
@Excelsiur1 Жыл бұрын
This worked perfectly for me as well. Go step-by-step and double check all of your settings and values. Seems to be working for everybody else.
@gizmo95 Жыл бұрын
It seems like the initial velocity makes the sun drift! I added a simple if statement to check if it's the sun. this seemed to fix it.. although a bit of a hack! if(a.name != 'sun'){ a.GetComponent().velocity += a.transform.right * Mathf.Sqrt((G * m2) /r); }