-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDScript variable chained assignment fails when an intermediate variable is readonly. #41319
Comments
Edit: This works if you create and use a local reference to your collider. code
extends KinematicBody2D
func _physics_process(_delta):
var coll: KinematicCollision2D = move_and_collide(Vector2.LEFT * 50)
if coll != null:
var c: KinematicBody2D = coll.collider
#print(c.name)
if c.name == "Stationary":
c.value_to_set = true
if "value_to_set" in c:
c.value_to_set2 = true extends KinematicBody2D
var value_to_set := false
var value_to_set2 := false
var once := true
var once2 := true
func _process(_delta):
if value_to_set and once:
print("value_to_set:", value_to_set)
once = false
if value_to_set2 and once2:
print("value_to_set2:", value_to_set2)
once2 = false |
Interestingly,
As @capnm suggested the workaround is to set the value in two lines:
|
Isn't there any other report about this? This is known for a while but we couldn't yet think of a good solution. |
@vnen I think I've stumbled upon exact same issue as described here, I've implemented a See detailed bug report at goostengine/goost#17 for more information. |
Can't reproduce this in RC 2 because the See also:
I can't say for sure, but judging by the description of the PR, this issue has been fixed in 4.0. Whether we can do something about it in 3.x I don't know. |
Tested with this in 4.0 RC 2, it works fine:
|
Godot version: 3.2.2
OS/device including version: Windows 10
Issue description:
if you run move_and_collide on a KinematicBody and it collides with something, you can't set a value on the collider you hit, it throws the error:
"invalid set index 'collider' (on base: 'KinematicCollision2D) with value of type 'KinematicBody2D"
the example shown here: https://docs.godotengine.org/en/stable/tutorials/physics/using_kinematic_body_2d.html
does not work
Steps to reproduce:
Have to kinematic bodies next to each other, one has this code:
the other has this:
Minimal reproduction project:
SetIndexBugKinematic2dColl.zip
The text was updated successfully, but these errors were encountered: