I have a bullet object. I'd like to change the speed of bullets if the player triggers some event.
Is there a way to edit the properties of objects at runtime?
Of course I can change bullet speed and all the bullets currently on the screen will change. But it won't impact future bullets. I want to impact future bullets and not current bullets.
You can't directly change the default values of an object at runtime, but you can use global variables to define values that you want to change.
For instance, create a global variable called "bulletSpeed" and make it 100
Then when a bullet is created, you set it's speed to "bulletSpeed". That means the bullet will receive the value stored in "bulletSpeed"
Now if you want all bullets in the future to be faster, you just need to change "bulletSpeed" to another number, and that will keep working even if you change layouts
Manual page on variables
Develop games in your browser. Powerful, performant & highly capable.
Thank you for your help that works perfectly