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.
No comments:
Post a Comment