"Object Variables"- Suggested feature..

Discussion and feedback on Construct 2

Post » Mon Jan 30, 2017 11:07 pm

I have been using construct 2 for a long time now. And there is one feature, that I have wanted my entire C2 career. And that feature is, "Object Variables". What I mean by "Object Variables" is, a new type of variable, that could store an object in data. If you don't understand, let me give an example. You create a object called "Weapon". You than create a Object Variable called "Holder". You than spawn, "Weapon" and set "Holder", to a object called "Player". You than say, Every Tick, set "Weapon" Position, to "Holder". This is obvious, a crude example, and I am sure if this feature was added, the community could do so much more! This might already be possible in C2. If this is already possible, I would love somebody to tell me.
B
20
S
3
Posts: 52
Reputation: 1,073

Post » Mon Jan 30, 2017 11:09 pm

Have you tried using containers?
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,986

Post » Mon Jan 30, 2017 11:24 pm

Burvey wrote:Have you tried using containers?

Containers, work well, for one set of objects. While "Object Variable" Would work for many objects.
B
20
S
3
Posts: 52
Reputation: 1,073

Post » Mon Jan 30, 2017 11:33 pm

Your 'holder' object var can be a instance variable in 'weapon' that holds a UID. You then have your 'owner' object reference.
Image
B
30
S
9
G
3
Posts: 171
Reputation: 3,329

Post » Mon Jan 30, 2017 11:34 pm

I'm not quite sure if I understand what do you try to achieve exactly, but if you try to encapsulate data in an elegant way, you may want to take a look at Globals plugin approach http://tobyr.wtfgamesgroup.com/c2-plugins/globals-construct-2-plugin-alternative-for-native-global-variables/.

You can create various instances to encapsulate specific data.
ImageImageImage
B
27
S
16
G
74
Posts: 981
Reputation: 41,681

Post » Tue Jan 31, 2017 2:07 am

I think what he is wanting is a simpler way to pair objects together.
Image ImageImage
B
169
S
50
G
169
Posts: 8,291
Reputation: 108,226


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 40 guests