8 direction behavior question

For questions about using Classic.

Post » Mon Jan 31, 2011 11:46 pm

Hi everyone,
How can I set the angle of one object away from another? I'm trying to have one sprite run away from another. Having one chase another is so easy, and I'm sure the answers a no-brainer but I can't seem to get it!
B
3
G
1
Posts: 23
Reputation: 521

Post » Mon Jan 31, 2011 11:54 pm

Try this:
[code:2b89fxhs]0 - angle(sp1.x, sp1.y, sp2.x, sp2.y)[/code:2b89fxhs]
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Feb 01, 2011 7:29 pm

Thanks, Deadeye. That produced some interesting results where the object moved around a little in random directions relative to the player, but it didn't 'run away'. I take it then, that there is no simple way to do this?
B
3
G
1
Posts: 23
Reputation: 521

Post » Tue Feb 01, 2011 7:41 pm

Shouldn't it be simply 'move at angle: angle(sprite.x, sprite.y, sprite2.x, sprite2.y)'? (Reverse the object names if it's backwards)
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Tue Feb 01, 2011 7:44 pm

Yeah, thanks guys. I'd just figured it out when Arima posted. Appreciate the help!
B
3
G
1
Posts: 23
Reputation: 521

Post » Tue Feb 01, 2011 8:30 pm

[quote="Arima":a09ndvls](Reverse the object names if it's backwards)[/quote:a09ndvls]

Oh yeah, huh? Oops. :oops:
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Feb 02, 2011 2:38 am

I too have a quick question about 8dir (and Custom movement), so I hope no one minds me asking my own question. : D


http://i417.photobucket.com/albums/pp25 ... oblem2.jpg

EDIT: there's a link there. I hate how this forum now seems to cut image sizes so it can fit within the forum template. Frustrating!

I'm using Custom Movement and 8 directions to make enemies that move from side to side and up-and-down. When they hit an object with the attribute 'Bouncer,' I want them to reverse their movement angle by 180 (so if an enemy is traveling right, it turns left; and if an enemy is going up, it turns down). However, none of the various solutions I've tried arrive at that outcome; the enemy hits the bouncer attribute object and then turns left invariably.
Check out my VGM on my soundcloud page!
Video-Game Music: E.C.2151
B
7
S
2
G
2
Posts: 193
Reputation: 1,561

Post » Wed Feb 02, 2011 3:05 am

I'm not sure, but I think you cant set the angle of the 8-direction behavior to 90, I believe it's range is from 0 to 7 like this:
3 2 1
4 # 0
5 6 7
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests