Target object via variable

Get help using Construct 2

Post » Fri Mar 30, 2012 5:56 pm

ok didnt see anything like this in the tuts, atleast not with a search
I am thinking i might need to use global variable text arr ie "|en1|en2" etc

how can I target an object via a specific variable?
Ie i set one objects variable to enemy.UID

So that this object can behave towards this specific ID
so if variable = enemy, behave towards this specific instance of this object

Does that makes sense? is this possible?

if not how about putting the enemy in the array ie global text variable = "|en1|en2"
target the specific object via int(tokenat(globalar,slot,"|"))

and then the object i want to act towards this specific object can get the slot in the array, and target it that way?

does that make sense? are these things possible?
is this something i need a standard version to do?


Note: im trying to avoid using tons of for statements to target both objectscs2curious2012-03-30 17:57:44
B
9
S
4
G
3
Posts: 223
Reputation: 3,433

Post » Fri Mar 30, 2012 6:20 pm

for each object
object: if variable = what youwant

I think that is all you need? If not, could you please try to be a little clearer on what you want.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Mar 30, 2012 6:50 pm

omfg hating this forum it logged me out and deleted my message grrrrr!~

thats just it i want to do it without the for statement
I want to say object1.variable = object2

Oject1 do thing to Self.Variable'

I want to target the specific object by getting the objects variable without tons of laggy for statements

cs2curious2012-03-30 18:51:25
B
9
S
4
G
3
Posts: 223
Reputation: 3,433

Post » Fri Mar 30, 2012 6:53 pm

omfg it deleted my post again and made me retype it!!!!

*pant pant*

for example     Self.X = Self.Variable.X   the variable being the other objects name instance

again trying to do it without laggy for statementscs2curious2012-03-30 18:54:38
B
9
S
4
G
3
Posts: 223
Reputation: 3,433

Post » Fri Mar 30, 2012 7:17 pm

seriously? no way to do this? is this something famalies do automatically?

dont act like im talking in tongues, any other coding language can do this,

variable = object

this.X = variable.X   the variable being the target namecs2curious2012-03-30 19:18:07
B
9
S
4
G
3
Posts: 223
Reputation: 3,433

Post » Fri Mar 30, 2012 7:18 pm

Explain/show some context. You probably have a game situation where you need to do something like this. It's easier to explain with context.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Mar 31, 2012 6:23 pm

eh, not sure if it matters from what i can tell you HAVE to have the for statement to target both object types:

For each object 1
for each object 2
if object 1 variable = object 2 unique id, follow this object

i mainly wanted it so i can do different monster types and only use 1 animation i did using image points
the arm, leg head etc will be seperate, and will attach to the unit it self, so i want it to follow the image points animation of the specific object it is attached to
( the objects for example arm will get the point and rotation of the image points in the animation to determin its position, making an animation, I do this so i dont need 8 billion sprites to have different looking characters running left right up etc, as it is going to be isometric)

I dont want to use ' get closest' because should 2 units get really close to eachother I dont want limbs betraying their object body XD
cs2curious2012-03-31 18:25:03
B
9
S
4
G
3
Posts: 223
Reputation: 3,433

Post » Sat Mar 31, 2012 7:47 pm

only one of the "for each"s are needed

object1 is the child object type,
object2 is the parent object type.

For each object1
object2 | Pick instance with UID object2.variable
---- object1| follow object2
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755


Return to How do I....?

Who is online

Users browsing this forum: armaldio, ETgirl79, TiagoCesar and 22 guests