0 votes

Hi, and thanks for reading my question.

Okay, so I am a newbie at this Godot and 3D engine thing. I took several tutorials, written and video, such as BornCG's video game tutorial, so I have some rudimentary knowledge, but not much.

I am making a 3D dice game and after the appropriate number is achieved, I want to whisk the dice away to the side of the playing table so it is out of the way. I read through vector math and came up with these options:

$pirateShip.show()
        var oldPosition = get_node("LowPolyDiceC").get("dicePosition")
        var targetPostion = get_node("pirateShip").get("shipPosition")
        var newDirection = targetPostion-oldPosition
        print(newDirection)
        $LowPolyDiceC.apply_impulse(Vector3(),newDirection)

        #translate(translation.direction_to(newDirection))
        # This one only moves a tiny bit, and not in the right direction.

        #translation.direction_to(newDirection)
        # This one doesn't move at all.

        #apply_impulse(Vector3(),newDirection)
        # This one rockets it towards the ship, then it falls off the table.

        #translate(newDirection)
        # This one does not go to the ship, but goes up in the sky near it.

However, none are quite what I want.

The apply impulse option moved the dice in the right direction, but then it just keeps going. And, if there are other dice in the way, it knocks them over, which I do not want to change the other dice at all.

Using translate, I can magically move the dice, but I am not able to put it where I want. I know this is a math problem, but my vector math is a bit weak. Using the math I have, the dice moves up equal in height with the ship, but off to the side.

So, how do I properly do this math to magically move the dice to a given point (the pirate ship)?

If you need more information, here is my project on GitLab:
https://gitlab.com/alaskalinuxuser/game_ship_captain_crew

and more specifically, this script:
https://gitlab.com/alaskalinuxuser/game_ship_captain_crew/-/blob/master/scripts/GameTable.gd

Any pointers are appreciated, I've spent several days reading documentation, and I am still stuck. I appreciate you help!

-Alaskalinuxuser

in Engine by (12 points)

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.

Categories