Need some help coding custom vector directions overriding engine physical parameters. Possible?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Euergetes

The Project I am working on is a simulation of the “1976 PONG for Your Home TV” dedicated console game. This system, by Atari, offers the game in colour. The game isn’t simulated anywhere and I would like to have it in my arcade. It is also the prototype project of its kind which knowledge and skills derived from will enable me to simulate other games of the period. Now, a little bit about the game that pertains to my question:

Due to the design of the game, some parameters are outside the way the Engine handles projects. What I mean by this is,

The PONG paddles have “regions” in them that, for example, sends the ball in the x direction if the point of contact occurs squarely in the center of the paddle. It does not matter what the incoming direction of the ball is nor whether or not the paddle is moving.

I have created a CollisionPolygon2D of one of the paddles with contoured surfaces representing, 45, 60, 75, and 90-degree angles from the top front to the center of the paddle and these angles in reverse to the bottom front.

To avoid confusion here, I am referring ONLY to the front of the paddle, not the top and bottom planes yet.

As in the example above, the other surfaces do the same thing.

Going from the paddle’s center out to the top and bottom (along the y axis) we have:

90-degree surface returns a 0-degree (x-axis only) trajectory.
75 returns a 15,
60, a 30
45, a 45

The first thing I found out, using polygon shapes for the first time, is that the contours do effect the trajectory however, it negates the direction from which the ball contacted it, and I don’t want this.

I am basically trying to get the ball to be sent in a trajectory path perpendicular to the surface the ball came into contact with, no matter what incoming trajectory the ball was before contact or whether or not the paddle is in motion…

Can this be done in Godot? I have been using 2.1.4 because there is much more in the way of tutorials and discussion than there is for 3.1.0.

Any thoughts, ideas or discussion is greatly welcomed and appreciated. I am new at this so please have some patience with me.

Thank you kindly!

:bust_in_silhouette: Reply From: flurick

I suggest marking the different areas of the paddle with multiple different colliders and then rotating the ball with your own functions, based on which collider the ball enters. Since you in this case don’t want the behavior of the built in collision system, use as little as possible of it. Maybe it is even enough to use move_local_x() and rotate(rad2deg())

Okay, this does open a new avenue for me. I will look into the move_local_x() function however, I do not want the ball to rotate. I think I understand what you are saying about multiple colliders in the paddle. I have thought of this but the idea of creating a contoured one took precedence.

The problem I am having with going the polygon method is that, in order to make the ball have collision with the angled surfaces I have in the shapes requires insteps, or stair-steps. If the ball hits one of these, or the points this produces, it makes the ball go off in undesired trajectories.

This design will not work for the game. Your idea sounds better!

So, what would happen then is, if the ball hits the front surface of the top collider, the ball would go at a 45=degree angle (or (1.0, -1.0) and so forth, using vector coordinates for each layer down, coming up with coordinates that would produce each vector angle. Then, the next one down, to produce a 30-degree angle would be something like (1.0, 0.66) or something like that.

In fact, I will be experimenting with this exact angle as the game in question always begins by serving the ball at a 30-degree angle to the Right Player.

I will need the right code for the colliders. If this works in the starting velocity, it should work in a script, once I understand more about this.

I do understand the concept though and will be turning in this direction.

Thanks for the ideas!

Euergetes | 2019-04-01 21:46