Elliot Cullen
Elliot Cullen

Reputation: 55

How can I attract Rigidbody 2d nodes to the player (using point gravity) even when the player is moving in Godot?

So I am asking this question here because I haven't gotten a response on the official Godot forum. I am really hoping someone answers here :),

I am making a game using Godot 3.0, and the main functionality is the player uses their gravity to direct and divert enemies from a target.

I am stuck on this, as I am new to Godot and unsure as to how to attract rigidbody2d's using point gravity from area2d. Currently, my player and enemies collide and the player can hinder the enemies movement by this, but the AoE gravity does not affect enemies.

I am open to any suggestions, or other ways to do it. Code examples would be greatly appreciated :) (I am using Godot script)

Currently, my scene consists of:

Player (KinematicBody2D)

Enemy (RigidBody2D)

And other things but they are not necessary.

If you need my code/project I am happy to provide it. Constructive Criticism is appreciated

Upvotes: 1

Views: 988

Answers (1)

jeudyx
jeudyx

Reputation: 777

I think this will help:

https://godotengine.org/qa/50288/two-rigidbodies-attracting-each-other-with-area-nodes

I did something similar, but didn't set the global project gravity to 0. The key is in the space override. Then you can play the values to adjust what you want. In my case, I wanted my character (A KinematicBody) to have an effect similar to Kirby's, so my character attracts these little bouncing white balls (Rigig Bodies):

enter image description here

Upvotes: 0

Related Questions