How do I store a reference to an instance in a variable?

Get help using Construct 2

Post » Fri Jan 06, 2017 7:59 pm

I'm making a camera using lerp...

I want to build a system that can easily change wich object the camera object should follow. I made a global variable "CameraFollowObject" and give it the value "Player".
Now for the camera object I want to make a lerp expression like this: lerp(self.x,CameraFollowObject.x,0.1) but C2 won't let me. Is this a bug or just a flaw in C2?

Is there another way to do this?
B
32
S
10
G
6
Posts: 259
Reputation: 6,776

Post » Fri Jan 06, 2017 8:05 pm

You are storing a string (text) not the object. It can't possibly work. Place the objects you want into a Family, then store the UID of the object to follow. Pick the Family object by UID, and do your lerp (by Family.X, etc).
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Fri Jan 06, 2017 8:48 pm

blackhornet wrote:You are storing a string (text) not the object. It can't possibly work. Place the objects you want into a Family, then store the UID of the object to follow. Pick the Family object by UID, and do your lerp (by Family.X, etc).


Yep that woked! Thanks for helping :)
B
32
S
10
G
6
Posts: 259
Reputation: 6,776


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests

cron