#node referring to it's parent is somehow referring to all parents of the instanced scene?

8 messages · Page 1 of 1 (latest)

wheat crow
#

the code used is $CollisionShape2D.shape.extents = get_parent().region_rect.size * 0.5

it's ran by the area2D in this heiracy, and is instanced multiple times in the level as a resizable gimmick.

#

when used in the level, all wind gets the same collision box

#

it uses the last processed one for all

#

it doesnt matter when it runs either, this was happening while calling the function from _physics_process()

wheat crow
#

here's the whole script actually

extends Area2D
tool
var players = []

# Declare member variables here. Examples:
# var a = 2
# var b = "text"

#upward wind doesnt seem to like working so...
#eh.

# Called when the node enters the scene tree for the first time.
func _ready():
    $CollisionShape2D.shape.extents = get_parent().region_rect.size * 0.5
    #rotation = get_parent().rotation
    


# Called every  uhyhhhhh frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
    _ready()
    var parent = get_parent()
    for i in players:
        i.movement.x += sin(parent.rotation)*parent.speed*delta*3.5
        #i.movement.y += cos(parent.rotation)*parent.speed*delta*7


# this is like forceroll.gd
func _on_Area2D_body_entered(body):
    if !players.has(body):
        players.append(body)

func _on_Area2D_body_exited(body):
    if players.has(body):
        players.erase(body)

severe ivy
#

Collision shapes (the data about the shape, not the collisionshape node itself) are stored as Resources, which basically means that changing the size of one shape will change all of the instances of that shape. I believe if you go into the inspector on the collisionshape, you can check the collisionshape resource's "local to scene" checkbox which will make each able to be changed independently at runtime.

wheat crow
#

Thank you!

#

I was honestly ready to rewrite the whole gimmick