May i ask for assistence in coding my new game? Thank you

I am currently making a first person shooter-type game and i am having trouble with shooting.
I made a small section of code in which it launches the rocket and once it collides into somthing it is suppose to re-attach back. but most of the time it glitches out and doesn’t work,here is the link:

1 Like

Hi @Daniel_Ornelas nice job on the code so far, and clever use of a bunch of cospace’s functionalities to create the animations.

The problems you were getting were in part due to having an “on pressed” event for firing the rocket; These events will trigger dozens of times per second as long as the button is pressed. Causing your rocket to fire 20 times a second or so.

A second issue was with the collision, by having a bigger collsion box the computer has an easier time to see if an item has collided especially when the item moves fast. I’ve created this by putting the rocket inside of an invisible cube, I renamed this cube to your original rocket pew pew, and the rocket model to rocketModel.

Lastly using functions is a good way to keep your code readable and easier to debug. They can be created at the red “function” tab by pressing create function. I’ve used this in your updated code.
I did end up changing the rocket behaviour a bit by having it detach from parent early, so that the player can no longer adjust the rockets path when fired.

Throughout the code I’ve added a bunch of comments (brown blocks) explaining each part to help you understand why I did things a certain way, you can read them in full by clicking on them.
Hope this helps, Happy coding!

Many thanks,@Luc,this has helped me alot,thank you!

1 Like