Returning Bullets

For questions about using Classic.

Post » Sat Aug 08, 2009 5:31 am

I'm glad I found this program. I've been fiddling around with all sorts of things for years and never really found a good outlet for my game ideas. I like that it's easy to pick up and figure out how things work simply by fidgeting with them. That said, I've got a snag.

I'm making a platform game where a person, equipped with a bat, can hit projectiles to prevent being hurt by them. Deflecting them away is easy enough, but I'd like to be able to return the bullet to the enemy that spawned it, which will in turn destroy it, and I'm not too sure how. Playing with the bullet behavior, I found if I rotated it 180 degrees it would fly in the opposite direction. But with moving targets, it'd be pretty difficult to hit anything that way. I can make the bullet home in on the player by telling it to look at her, but trying to do the same to the enemy will make it aim at the nearest instance of the enemy rather than the one that shot it. Is there a way to be more selective of which instance the bullet will look at?

Thanks for reading and in advance for the help.
B
1
G
3
Posts: 3
Reputation: 831

Post » Sat Aug 08, 2009 5:44 am

There are a couple ways to do that. Since your already using the bullet behavior I would do an on collision event when you want the bullet to return just use the action rotate toward object, with the amount of rotation set pretty low.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Sat Aug 08, 2009 6:10 am

Yes I've tried that, but like I said, when there's more than one instance of the same enemy, the bullet will rotate toward the one closest to it, not necessarily the one that spawned it. Unless I'm missing something here...
B
1
G
3
Posts: 3
Reputation: 831

Post » Sat Aug 08, 2009 8:01 am

You can have the bullet remember UID of its shooter and have it turn toward the enemy matching that UID.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sat Aug 08, 2009 8:14 am

Heh was just going to say the same thing.
Any way use a private variable, and make the pv the uid of the shooter.
Here's an example.

[url:36sue0r3]http://dl.getdropbox.com/u/666516/rotoud.cap[/url:36sue0r3]
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Mon Aug 10, 2009 4:10 am

Ah I think I understand. Thank you, I'll try it out.
B
1
G
3
Posts: 3
Reputation: 831


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest