How do I make a variable refer to an object?

Get help using Construct 2

Post » Wed Dec 21, 2016 2:39 am

I am building a top-down shooter where the player can equip various guns.

I want a variable, currentGun, so that I can switch between guns while keeping code for a general gun intact.
(ie. createObject(currentGun.Bullet) - to fire the gun )

currentGun would refer to other gun objects. (e.g. /*player equips FireGun then,*/ currentGun = FireGun)

How can I do this in Construct 2?
B
5
Posts: 4
Reputation: 233

Post » Wed Dec 21, 2016 3:17 am

Just add a text variable, name it "currentGun".
When you equip the gun, add an event "currentGun": set to [gunname].

The exact way how to do this depends hardly on the way your weapon/equipment system works.
So if you need more help, e.g. on how to get the gun name, you need to share some details, or, even better, the .capx of your project.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091


Return to How do I....?

Who is online

Users browsing this forum: jasontoups, OddConfection and 3 guests