Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | jagc |
I’m currently following this tutorial by @kidscancode
I’m only at part 1 and I’ve already hit a wall
via this line: transform = target.orbit_position.global_transform
The error shown in the title happens after the object/node ‘jumper’ hits the object/node ‘circle’ upon running the scene.
The root/parent-most node of each scenes colliding that are attached to each of the scripts are of type: Area2D
This is the code of the problem script:
jumper.gd
extends Area2D var velocity = Vector2(100, 0) # start value for testing var jumpSpeed = 1000 var target = null # if we're on a circle func _unhandled_input(event): if target and event is InputEventScreenTouch and event.pressed: jump() func jump(): target = null velocity = transform.x * jumpSpeed func _on_jumper_area_entered(area): target = area velocity = Vector2() func _physics_process(delta): if target: transform = target.orbit_position.global_transform else: position += velocity * delta
This is what it’s hitting.
circle.gd
extends Area2D onready var orbitPosition = $pivot/orbitPosition var radius = 100 var rotationSpeed = PI func _ready(): init() func init(_radius = radius): radius = _radius $CollisionShape2D.shape = $CollisionShape2D.shape.duplicate() $CollisionShape2D.shape.radius = radius var imgSize = $Sprite.texture.get_size().x / 2 $Sprite.scale = Vector2(1, 1) * radius / imgSize orbitPosition.position.x = radius + 25 func _process(delta): $pivot.rotation += rotationSpeed * delta
I watched the video version of the tutorial and changed my project settings and everything else accordingly but the result is still the same.
Any ideas/hints to fix this?
Env:
Godot 3.1.1