Why do the Areas repell each other?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By toblin

Why do my Area objects repel each other? I.e. why can’t they pass through each other without being affected by physics? How do I make them be able to pass each other through?

The blue solid spheres seen here are RigidBodies with their own CollisionShapes. The large outer “invisible” spheres are the CollisionShapes of the areas attached to the RigidBodies. I’m expecting that the RigidBodies should not be able to pass each other through. I do however expect the large collisionShapes to pass each other through.

enter image description here

Below is the custom script that defines the RigidBodies with the Area and CollisionShapes attached. The two ball-entities seen in the GIF are instances of this script.

# Cell.gd: Custom script  that is not attached to a Node.
# Is instanced in Spatial.gd below

extends RigidBody

var area
var outersphere
var innersphere
var visualsphere

var collisionshape_inner
var collisionshape_outer
func _ready():
 	# create shapes
	outersphere		= SphereShape.new()
	outersphere.radius = 4.0
	innersphere		= SphereShape.new()
	visualsphere 	= CSGSphere.new()

	# create collision shapes
	collisionshape_inner = CollisionShape.new()
    collisionshape_outer = CollisionShape.new()

	# add collisionshape_inner as child to rigidBody

	# add an area to the rigidBody
	area = Area.new()
	# add collisionshape_outer to the area
	add_child_below_node(area, collisionshape_outer)
	# add visualshape to rigidbody

The main scene is a Spatial.tscn, with the following attached script:

# Spatial.gd. Attached as a script to a Spatial node in the 
# node tree and main scene

extends Spatial
var Cell				= load("res://Cell.gd")
var zygote = Cell.new()
var zygote2 = Cell.new()

func _ready():

	zygote.translation = Vector3(-20,0,0)
	zygote2.translation = Vector3(20,0,0)
func _physics_process(delta):
	var v_21 = zygote.translation - zygote2.translation
	var v_12 = -v_21
	zygote.add_central_force( v_12*1 )
	zygote2.add_central_force( v_21*1 )
:bust_in_silhouette: Reply From: rustyStriker

Add_child_below_node doesnt add the child to the second node but as a brother(aka same parent)
so what you want to do is use the get_node or $ to get the area node and then do something like

 $AreaNodeName.add_child(Collision Sphere)


 get_node(AreaNodeName).add_child(Collision Sphere)