0 votes

Hi everyone!
(This this my first post here, been reading a lot! Thank you for all of the help already )

I am working on a Tetris clone, learning/practice project. I have some experience with game engines such as ue4, but this is first thing I am trying to do with Godot.

I have the whole thing sort of put together.I first made a 2d version, now I am trying to convert it to 3d,... it is somewhere in-between atm ^^. I started facing some difficulties when I started figuring the 3d transforms for Spatial nodes.

My Tetrominos are currently made out of tiles which are instanced Spatials. I do create those at run time and parent them to another root node, which is also a Spatial. For each tile in tetromino I have added .translation offset. When I rotate the tetromino I do rotate the parent node. This whole system is probably not the smartest thing but it is the current state of things.

what I am trying to achieve:
I am just simply trying to drop an array of objects to world.z direction.

How it is behaving now:
When i try to set translation to tiles it is transforming objects to various directions. I assume there is local rotation and everything moves in their own "space"

Solution to this is probably something very simple but I seem to be missing something. TLDR: How to move something -Z in World Space. and ignore the something rotation.

This works but I am pretty sure this is not how it should be done ^^.

    for t in tiles:
    var stored_origin = t.global_transform.origin
    if t.get_parent():
        t.global_translate(stored_origin + drop_offset)
in Engine by (21 points)

2 Answers

+2 votes
Best answer

Translate() moves in local space, so there are two ways of doing this.
1- keep what you already have but parent each shape to a spatial node that doesn't rotate.
2- create a separate spatial node and use it for the direction with the xform() method

by (3,257 points)
selected by
+1 vote

Thank you.

I did solve it with Transform.translated in my loop:

Spatial.set_global_transform(Transform.translated(Spatial.get_global_transform().origin + Vector3(0, 0, -1)))
by (21 points)
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.