0 votes

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:

extends Area2D var velocity = Vector2(100, 0) # start value for testing
var jumpSpeed = 1000
var target = null # if we're on a circle func unhandledinput(event):
if target and event is InputEventScreenTouch and event.pressed:
jump() func jump():
target = null
velocity = transform.x * jumpSpeed func onjumperareaentered(area):
target = area
velocity = Vector2() func physicsprocess(delta):
if target:
transform = target.orbitposition.globaltransform
position += velocity * delta

This is what it's hitting.

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?

Godot 3.1.1

in Engine by (92 points)

1 Answer

0 votes
Best answer

I guess it's just typo.

you are referring orbit_position in jumper.gd

transform = target.orbit_position.globaltransform

but it's defined as orbitPosition in circle.gd

it's simply orbit_position vs orbitPosition

by (9,784 points)
selected by

Thank you so much!

I didn't know that area from the _on_jumper_area_entered(area) method was actually an object referring to circle.gd

This really helped! Thanks!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.