How do I make a everytick function to a single object

Get help using Construct 2

Post » Tue Oct 18, 2016 11:04 am

Hello there! I have one question...

I have 1 object (Sprite) with 3 instances. I want to make a function (or anything like) that have a code animation, not sprite animation. For example:
Die animation:
When an object dies, i want to make an animation with his death to that instace. How do i do it? Can i bind an object to an evertick function (or anything like)?
Last edited by andykenobi on Tue Oct 18, 2016 12:05 pm, edited 1 time in total.
B
14
S
6
G
2
Posts: 81
Reputation: 2,241

Post » Tue Oct 18, 2016 11:39 am

What triggers the death animation? If it is an instance variable for health reaching 0 then the event 'object health=0 - trigger death animation' will work for each instance.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Tue Oct 18, 2016 12:05 pm

plinkie wrote:What triggers the death animation? If it is an instance variable for health reaching 0 then the event 'object health=0 - trigger death animation' will work for each instance.


But, it is a trigger, it will execute one time... i need to execute evertick (60 frames per seconds) got it? Becouse the animation is in code, not the sprite animation.
B
14
S
6
G
2
Posts: 81
Reputation: 2,241

Post » Tue Oct 18, 2016 12:10 pm

Most events trigger every tick without you having to change anything. I'm not sure what a 'code animation' is so I'll let someone else follow this up. It's probably easy to do I just don't understand what you want.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Tue Oct 18, 2016 12:15 pm

plinkie wrote:Most events trigger every tick without you having to change anything. I'm not sure what a 'code animation' is so I'll let someone else follow this up. It's probably easy to do I just don't understand what you want.


Okay, let me explain it. I'm make a "lerp" animation with moviment. If i use a trigger, the "lerp" function will not execute... I need to evertick. Got it?
B
14
S
6
G
2
Posts: 81
Reputation: 2,241

Post » Tue Oct 18, 2016 1:03 pm

Maybe something like: Add another Variable, start it at 0, call it "Timer", set the death condition to: health<0 and Timer<60 -> your code stuff, plus add 1 to "Timer".

On Timer=60, destroy object.
B
16
S
6
G
1
Posts: 29
Reputation: 1,656

Post » Tue Oct 18, 2016 1:53 pm

benpalgi wrote:Maybe something like: Add another Variable, start it at 0, call it "Timer", set the death condition to: health<0 and Timer<60 -> your code stuff, plus add 1 to "Timer".

On Timer=60, destroy object.


Good idea, i will try. Some one have another idea?
B
14
S
6
G
2
Posts: 81
Reputation: 2,241

Post » Tue Oct 18, 2016 2:15 pm

When i use a lerp, i usually do it with a timer combined with a boolean.

This way i can restrain the lerp and i know when it ended. By instance.
https://www.dropbox.com/s/sa8g4v7lkj08s ... .capx?dl=0

Cube is a lerp with 4 points. Nothing new.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Oct 21, 2016 11:30 am

99Instances2Go wrote:When i use a lerp, i usually do it with a timer combined with a boolean.

This way i can restrain the lerp and i know when it ended. By instance.
https://www.dropbox.com/s/sa8g4v7lkj08s ... .capx?dl=0

Cube is a lerp with 4 points. Nothing new.


Cool, but it will work if one object have many instances?
B
14
S
6
G
2
Posts: 81
Reputation: 2,241

Post » Fri Oct 21, 2016 6:12 pm

Of course, timers are personal. That is the point. Boolean's are personal too.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Next

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, David181, tarek2, Yahoo [Bot] and 19 guests