2nd revision
1. Ball object added code to make the ball fly backward or z-axis when shot.
2. Ground scene, line 10, multiply the camera distance value, in this case 30.
var to = from + camera.project_ray_normal(event.position) * 30
Delete line 19.
var to = from + camera.project_ray_normal(event.position) * 30
Delete line 19.
3rd edit
1. The ball object does not use code or Script = [Empty] because when the ball hits the ground, there is no physics or bounce to any side.
2. The ground scene, add a vertical ground so that the ball can hit. Then enable line 19, edit the code to
balli.apply_impulse(to,Vector3(to.x,0,to.y*-5))
2. Box Scene A secondary box that balls can hit
3. Ball Scene The ball used for shooting
You will notice that where the mouse clicks, the ball will go that way. However, when you click on a corner of the screen, the destination of the ball is only in a square frame.
Solve the problem (by thinking yourself) by narrowing down the shooting of the ball. Shooting the ball will match the click of the mouse cursor, but the destination of the ball that shoots must be estimated by yourself.
What was fixed and changed
1. Main Scene Rotate the ground scene so that it is vertical and aligned with the Perspective camera plane.
1.1 Added a main box to release a secondary box that the ball can hit.
1.1 Added a main box to release a secondary box that the ball can hit.
![]() |
The code that makes the box float left and right is on lines 26-31. P.S. Line 16 to make the box float up and down like a sine wave but there is a BUG so # is used. |
1.2 Add Label to show the score of the ball that hits the box
1.3 Add Global.gd as a global variable that can be called in every Scene
2. Box Scene A secondary box that balls can hit
![]() |
Set Material by Albedo, insert existing Texture, UV1, enable Triplanar and adjust scale, offset. |
3. Ball Scene The ball used for shooting
![]() |
Set the RidgiBody to be Collision capable by enabling Contact Monitor, Contact Reported=1 and enabling Signal. |
![]() |
To keep it from using too many computer resources, the object must be destroyed using queue_free(). The computer will lag after shooting around 1500 balls (not exactly). |
The results obtained
1. Dotted lines are used to guide the direction of shooting the ball, following the mouse cursor.
![]() |
It is a small box that shoots out in the -z axis. There is no collision detection. |
2. Wall Use the provided godot.png image as a Texture. Create a Material. Set UV1.Triplanar = On.
3. Use SilentWolf's Leaderboard service just for testing.
![]() |
Add score to table
SilentWolf.Scores.persist_score("playername",score,"tablename")
Display score
yield(SilentWolf.Scores.get_high_scores(), "sw_scores_received")
print(SilentWolf.Scores.scores)
Test changing the camera to Orthogonal. The game display will look like 2D but the ball can be shot anywhere according to the mouse position.
Finally found the solution
From the question posted on godotforums
The walls have been removed, the World Environment has been changed, and the code for shooting the ball (apply_impulse) has been changed. You will notice that shooting the ball into the box has become easier, which is pleasing to gamers, but the details of the game are still lacking.
Let's play at https://gotm.io/abczezeze/shoot-only-gdsc
Script at https://github.com/abczezeze/Shoot-only-gdsc
No comments:
Post a Comment