Skip to content
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

Transform2D doesn't have same attributes as in GDScript #346

Open
MarioMey opened this issue Jul 14, 2022 · 1 comment
Open

Transform2D doesn't have same attributes as in GDScript #346

MarioMey opened this issue Jul 14, 2022 · 1 comment

Comments

@MarioMey
Copy link

MarioMey commented Jul 14, 2022

By trying the first code of the Matrixes and Transformation documentation, I do this:

from godot import exposed, Area2D, Transform2D
@exposed
class Coso(Area2D):
	def _ready(self):
		t = Transform2D()
		t.x *= 2
		t.y *= 2
		self.transform = t

... and I get this:

Traceback (most recent call last):
  File "build/x11-64/pythonscript/_godot_instance.pxi", line 98, in _godot.pythonscript_instance_call_method
  File "/home/mariomey/md-godot/test/TestTransform2D.py", line 13, in _ready
    t.x *= 2
AttributeError: 'godot.builtins.Transform2D' object has no attribute 'x'

So, the only way (I found) to achieve exactly the same, is:

from godot import exposed, Area2D, Transform2D, Vector2
...
		vx, vy, vo = Vector2(1,0), Vector2(0,1), Vector2(0,0)
		vx *= 2
		vy *= 2
		t = Transform2D(vx, vy, vo)
		self.transform = t

Why we can't modify a Transform2D object as in GDScript?

@MarioMey
Copy link
Author

MarioMey commented Jul 14, 2022

Also (as in here), it does exist but it is not writable:

from godot import exposed, export, Area2D, Transform2D, Vector2
@exposed
class Coso(Area2D):
	def _ready(self):
		t = Transform2D()
		t.origin = Vector2(350, 150)
		self.transform = t

Console:

Traceback (most recent call last):
  File "build/x11-64/pythonscript/_godot_instance.pxi", line 98, in _godot.pythonscript_instance_call_method
  File "/home/mariomey/md-godot/test/TestTransform2D.py", line 9, in _ready
    s.origin = Vector2(350, 150)
AttributeError: attribute 'origin' of 'godot.builtins.Transform2D' objects is not writable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant