How do I "constrain" a variable value to another?

Get help using Construct 2

Post » Tue Aug 01, 2017 1:54 am

Hi, I don't know the exact word to use since I in Gamesalad it's called "constrain", but I can't find the equivalent in Construct 2.

Basically, a variable will contain within it the same value as the one it's targetting at all times.

I need this because there is a self.attribute in enemies that keeps track of the X, Y of their target, and a third attribute that helps switch between targets. So basically, if the target value is 0, all enemies will keep track of the X,Y of the player, if the target value is 1, then it will keep track of the X,Y value of a different target, and so on.

Right now I'm using "every X seconds" and alternatively, every tick, but I would prefer something that just "constrains" the values?
B
20
S
7
G
1
Posts: 55
Reputation: 2,051

Post » Tue Aug 01, 2017 3:25 am

Every tick -> set value

That's how you do it in C2.

Alternatively, just use a blank condition (which is exactly the same thing as "every tick" just without having any visibly written condition)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Tue Aug 01, 2017 12:19 pm

Your program is doing a lot of things every tick so don't be too scared to use it. I did the same thing because it sounds like it would be a costly condition to use, but just think about the things you use this method for because often there is a way around it. For instance a Life Bar could checked 60 times a second or you could just change it when the player is damaged. Other things like the player facing the mouse cursor won't be able to avoid being looked at every tick.
B
8
S
2
Posts: 24
Reputation: 548

Post » Tue Aug 01, 2017 1:50 pm

Ok, thank you, for some reason, every tick didn't work for attributes within an object, since there where 30 objects to check, but going the "every x" route worked. It might have been that I had something wrong, but I will just go with this.
B
20
S
7
G
1
Posts: 55
Reputation: 2,051


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 14 guests