clemens-tolboom / godot_3_spawn_points

MIT License
3 stars 0 forks source link

Spawn Points system assumes products have a rect_position #16

Closed zaknafean closed 3 years ago

zaknafean commented 3 years ago

Describe the bug After setting up the nodes for use, an error was thrown at line. For me changing the line 58 to what's below fixes the problem:

if p.get('rect_position'):
    p.rect_position = global_position - node_to_place_products_into.global_position
else:
    p.global_position = global_position

To Reproduce Steps to reproduce the behavior: 1) Configure the SpawnPoint2D node to use an 'enemy' with a base node of KinematicBody2D 2) Run the scene. KinematicBody2Ds lack a 'rect_position' field, so we trip up at line 58.

Screenshots If applicable, add screenshots to help explain your problem. image

Device Info (please complete the following information): OS: Windows 10 Godot version: 3.2.3 godot_3_spawn_points version: master

Additional context This is a real time saver! Thanks for releasing it.

zaknafean commented 3 years ago

Played with the demo more, this code is more correct then what I originally posted.

if p.get('rect_position') != null:
    p.rect_position = global_position - node_to_place_products_into.global_position
else:
    p.global_position = global_position
clemens-tolboom commented 3 years ago

Thanks for your complete report. Working on it.

Note: you still need the - node_to_place_products_into.global_position as that is relative to the SpawnPoint position.

clemens-tolboom commented 3 years ago

Thanks for the fix

zaknafean commented 3 years ago

Yup seems including - node_to_place_products_into.global_position is an even better solution. This code is working great for my needs


if p.get('rect_position') != null:
    p.rect_position = global_position - node_to_place_products_into.global_position
else:
    p.global_position = global_position  - node_to_place_products_into.global_position
clemens-tolboom commented 3 years ago

I have to release a new version but that needs #5 #8 and #10 first I guess ... what do you think?

zaknafean commented 3 years ago

The change looks good to me! I'll close up the issue.