Today I finished the second tutorial video by adding physics to the cannon ball and effects when firing the cannon.
This is the added code that makes the cannon ball bounce off of surfaces when it collides in a realistic way. After doing this I added a sound effect for when the cannon fires, I did this by adding a sample player then adding the supplied sound effect to it. I then added a line a couple simple lines of code to make it play when the shoot() function is called. I also added a camera shake effect by adding a camera node to the cannon and then adding a animation player child node to the camera. from there I added 5 different camera offset frames every 0.04 seconds so the camera then shakes for 0.2 seconds every shot.
This is the current modified cannon code which plays all the new effects that have been added today in the images below.
Tomorrow I will be starting the next and what looks like the last part of this cannon tutorial series.
Tuesday, March 7, 2017
Friday, March 3, 2017
Learning Godot Day 10
Today I was able to fix the problem, it was a simple error that I overlooked involving me typing the incorrect function type into the code.
The "func _fixed_process(delta):" was lacking _fixed which I overlooked when originally typing the code. The cannon balls now fire and are projected as intended. The new function on the bottom is added through the visibility notifier node I added to the cannon ball node in order to destroy the excess cannon balls that go off screen so they aren't clogging p the hierarchy. Today I also created a tile through a texture that was given to me in the assets folder. Through this i made a 32x32 tile and was also able to create a tile map on the control scene which I find really cool about 2D in this engine. It allows me to paint the tiles I've saved onto the scene instead of filling up the scene with nodes.
This is the current state of the project, I will continue with the tutorial next day.
The "func _fixed_process(delta):" was lacking _fixed which I overlooked when originally typing the code. The cannon balls now fire and are projected as intended. The new function on the bottom is added through the visibility notifier node I added to the cannon ball node in order to destroy the excess cannon balls that go off screen so they aren't clogging p the hierarchy. Today I also created a tile through a texture that was given to me in the assets folder. Through this i made a 32x32 tile and was also able to create a tile map on the control scene which I find really cool about 2D in this engine. It allows me to paint the tiles I've saved onto the scene instead of filling up the scene with nodes.
This is the current state of the project, I will continue with the tutorial next day.
Thursday, March 2, 2017
Learning Godot Day 9
Today I continued from where I left off last day by continuing the tutorial which seemed to only consist of coding.
Above is the modified code from last day, this is creating a input when "ui_select" is pressed which is also equal to the space bar to make shooting true. _process(delta) always is called every frame so when its "if" statement detects the change in the state of "shooting it and the bullet delay of 1 second has reached it will call the function fire_once() and reset the waited time to 0 so the 1 second must be waited again before fire_once() can be called again. Once fire_once is called it will call the next function shoot() and set shooting to false again so shoot() wont be called more then once. Shoot will then carry out the process of spawning the cannon ball.
This script was then created and attached to the rigidbody2D of the cannon ball scene to carry out the process of how the cannonball will behave after being spawned by the cannon. Creating a gravitational pull and velocity of where its being launched.
I ran into a problem however where the ball spawns but does not actually move or spawn where the spawn point is at so I will have to look into this next class.
As you can see in the picture the cannonball is spawned in the center of the cannon and doesnt actually move which is a obvious problem that most likely has to do which the code of the cannonball script and/or instancing the cannonball into the scene.
Above is the modified code from last day, this is creating a input when "ui_select" is pressed which is also equal to the space bar to make shooting true. _process(delta) always is called every frame so when its "if" statement detects the change in the state of "shooting it and the bullet delay of 1 second has reached it will call the function fire_once() and reset the waited time to 0 so the 1 second must be waited again before fire_once() can be called again. Once fire_once is called it will call the next function shoot() and set shooting to false again so shoot() wont be called more then once. Shoot will then carry out the process of spawning the cannon ball.
This script was then created and attached to the rigidbody2D of the cannon ball scene to carry out the process of how the cannonball will behave after being spawned by the cannon. Creating a gravitational pull and velocity of where its being launched.
I ran into a problem however where the ball spawns but does not actually move or spawn where the spawn point is at so I will have to look into this next class.
As you can see in the picture the cannonball is spawned in the center of the cannon and doesnt actually move which is a obvious problem that most likely has to do which the code of the cannonball script and/or instancing the cannonball into the scene.
Subscribe to:
Posts (Atom)