How do I change an object's parameters at runtime?

Get help using Construct 2

Post » Tue Aug 25, 2015 9:56 am

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.
Posts: 33
Reputation: 345

Post » Tue Aug 25, 2015 7:56 pm

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
Posts: 1,039
Reputation: 15,249

Post » Wed Aug 26, 2015 2:52 am

Thank you for your help that works perfectly
Posts: 33
Reputation: 345

Return to How do I....?

Who is online

Users browsing this forum: Anonnymitet, DeXVinogradov, leena222, tatogame and 18 guests