Gravity basics in Unity (How to add gravitational fields to game objects)

Gravity basics in Unity (How to add gravitational fields to game objects)

ZeroKelvinTutorials

2 года назад

11,481 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Super Sentai Mexicano
Super Sentai Mexicano - 01.11.2023 21:41

Is there a way to expand this Script so it works with multiple planets each with a different gravity?

Ответить
LordForlorn
LordForlorn - 05.10.2023 00:39

To even more improve the system I would suggest dividing forceVector by mass of the target. That way we will get acceleration vector. Right now velocity of the object does not depend on mass -> light objects will give heavy ones same speed as vice versa, which is incorrect

Ответить
Pianist & cats
Pianist & cats - 30.07.2023 01:13

I watched the video and it's great :)
But I have some doubts about the code. Why when the law of universal gravitation is applied, G is used 2 times? How can I preview the orvite? Why are the orvites that are generated not ellipses or circles? And how can I make gravity not weaken so fast? I'm making a game where the size of the earth is about 500 radius units. What happens to me is that when I get the necessary gravity on the surface at a short distance, the force weakens a lot. Thank you :)

Ответить
BmD SCH
BmD SCH - 23.05.2023 15:50

Interesting video! I kinda want to do this but I am using java :/

Ответить
Pengi
Pengi - 21.12.2022 08:52

This helped me so much I do need a gravity simulation for a project but I had no idea how to do it, thank you

Ответить
Matt Majcan
Matt Majcan - 10.12.2022 07:10

this is awesome, thank you. I used this for my 2d space game, however i noticed that when im orbiting a planet with my ship, the ship stays oriented such that it will be pointing towards the top of the screen on both sides of the orbit when I believe/feel that the ship should be pointing down on one side and up on the other side. it should rotate with the planet. I'm not really sure how i can do that, if i should try adding a torque force, or just directly modify the ship's rotation somehow. i know in the real universe there isnt really a "force" doing this but rather "up" itself gets curved so but there must be a way i can 'cheat' and simply rotate the ship.

Ответить
Skippy The magnificent
Skippy The magnificent - 05.08.2022 00:13

LOL, Nice 🌏

Ответить
FM Productions
FM Productions - 11.05.2022 09:42

Really great video!
I've been working on something simiar for a fun a few years ago, where planets have gravity fields and objects are affected by any planet's gravity that is within range of the object. It was a lot simpler though, I just used a lienar falloff between a gravitational min radius, and a max radius, and outside the max radius, no gravity is applied. The planets also had triggers that cover that max radius, this is how I kept track of the planets that affect each object.

Ответить
Harshit
Harshit - 07.05.2022 13:13

I need help with line renderer
How can I draw a line form one point to another and it should be a free flowing drawing like I draw the line by myself and it only connects to the dot , that I want it to connect or else it resets, and if it collides with other line from other origin points it resets

Ответить
Night
Night - 04.05.2022 14:13

In order to make it more efficient I would replace "Mathf.Pow(distance,2)" to just "distance * distance".

But anyway it's very useful video!

Ответить
Rovsau
Rovsau - 04.05.2022 00:39

I am attracted to this video.

Ответить