Untitled Space Game
- 4 Devlogs
- 17 Total hours
Large-scale Cooperative Space Vehicle Combat Simulator
Large-scale Cooperative Space Vehicle Combat Simulator
This devlog adds a very nice feature: You can DIE now >:) The AI ship has now got access to a cannon and shoots whenever it looks at you. Along with a gun, the AI has also got a decent IQ boost to make it more challenging to defeat.
I have decided to add a state machine for the AI, which allows it to point directly at the player, shooting while flying towards them, then pull away just before colliding. This is also known as a Boom and Zoom technique
It achieves this with enum State { ATTACK, ZOOM} where the ATTACK is the ‘boom’ part and ZOOM is obviously the ‘zoom’ part. When the AI gets within 200 units of the player, it switches from ATTACK to ZOOM and flies towards a point 500 units above and 500 units in front of the AI, as seen here:
if global_position.distance_to(player_position) >= 200 and state_timer.is_stopped() and current_state == State.ZOOM:
current_state = State.ATTACK
state_timer.start()
elif global_position.distance_to(player_position) < 200 and current_state == State.ATTACK:
current_state = State.ZOOM
state_timer.start()
target_position = current_transform.origin + (forward_direction * 500) + (upwards_direction * 500)
For the AI ship’s weapon, I pretty much just copy and pasted the player ship’s cannon. In fact, the only thing different, was making a new scene for the enemy’s bullets to allow them to be on a different physics layer.
There is now a health indicator bellow the speed in the top left corner when piloting the ship, and when it reaches zero it destroys the player’s ship. I also needed to add 2 new CollisionShape3D for the player’s ship to collide with the enemy’s bullets, along with an extra, much bigger one that causes the enemy ship to shoot when it’s RayCast3D collides with it.
This devlog marks a very important milestone in this game. I am pleased to announce, there is finally something to do now! With this latest update, I have added an EXTREMELY smart (its not) AI ship which flies around chasing you, and also a cannon to shoot it down with.
For now, the AI ship is the same mesh as the player’s ship, but that will be changed later. As for the AI part, it simply uses an interpolate_with() line which gets the AI’s current location and the player’s current location, and puts out a transform for the velocity to use. It also pulls away just before hitting the player to not collide
For the health system, it simply has 2 CollisionMesh3D nodes in an Area3D which detects when the bullet’s CollisionMesh3D enters, and then subtracts 10 from the total health, and hides the enemy ship when health reaches 0
Of course the best part of the whole update is having weapons! Sadly, they are a bit lacking since it is literally just a small point that shoots (very glowy) projectiles at mach Jesus. The bullets also have their own CollisionMesh3D to interact with ships and OmniLight3D to add to their glowyness.
In this 3 hours, many bug fixes and new features were added. As for major bug fixes, the ship now flies without problem which previously didn’t work very well because I hadn’t assigned collision layers to the objects. Along with that, the character can now move flawlessly no matter what angle the ship is rotated at, which makes the game much more playable! Also, the player can now not enter the seat from any location, and now needs to walk up to the seat and look at it when pressing E.As for new content: There is now a sprint button (Left Shift) which doubles the players speed on foot, UI elements for when the player looks at anything interactable (for now only the seat) and also for the ship’s speed when piloting it, along with some atmospheric lights on the wings coming from the spotlights (which have been adjusted). Overall, the game is now playable without facing any bugs, but obviously lacks anything to actually do.
Basic 3D modelling for the first ship is well underway, along with some simple code allowing the player to move around the ship interior, and fly it!