Help with a movement behavior plz

Get help using Construct 2

Post » Tue Apr 10, 2012 5:20 am

Dude that method u used to calculate his direction is extremely complex hehehe but it works! Somethings u used in the event i have no idea what they are.. like 'floor' and this ">= 315 ? 0 :" part.. but once again thanks!
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Tue Apr 10, 2012 8:13 am

@Noga your formula is overcomplicated

First using the same angle order as c2 (0 is to the right and then you move clockwise) makes the formula way easier.
You can sum it up as round(animationFramCount*angle/360) but as you well representated in your image you need to offset the angle a bit so the direction the sprite shows represents the center of the range of angle and not the minimum.
So it should look like
[code]ceil(animationFrameCount*angle/360-0.5)[/code]
Then to avoid negative result (for angle from 0 to 180/animationFramCount),
you just have to offset values and modulo them
[code]ceil(animationFrameCount*(1+angle/360)-0.5)%animationFrameCount[/code]Yann2012-04-10 08:14:40
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Apr 10, 2012 9:31 am

@Yann
I've never been good at math, everything I do is trial/error. Yeah, I didn't know how to offset the angle, so I used conditions. I'll look into your example.

edit> That's exactly what I wanted, just didn't know how. Never though I'd regret I haven't been more attentive at math classes at school, what a paradox. Thanks Yann.Noga2012-04-10 13:45:42
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Tue Apr 10, 2012 2:05 pm

Its possible instead of animations frame, use new animations?? this way i can animate each of them.. im at work now so I didnt ever tried this yet
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Tue Apr 10, 2012 6:13 pm

Yes, use action "Set animation" and name them "0","1","2" and "3". Haven't tried it, but this should work.

Ok, can't use a number as the name, you'll have to use "&" operator.Noga2012-04-10 18:16:50
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Wed Apr 11, 2012 2:17 am

I've implemented the Yann's method and it worked very well, I also used different animations instead of anim.frames so It looked like:
"animation"&str(ceil(4*(1+angle(waypoint.X,waypoint.Y,units.X,units.Y)/360)-0.5)%4)

many thanks to Noga too for those useful tips and solutions ;)
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Previous

Return to How do I....?

Who is online

Users browsing this forum: austinblackbelt, makkancs and 35 guests