Thrown Object

For questions about using Classic.

Post » Wed Dec 10, 2008 12:46 am

I've run into a couple of snags with a system I'm trying to put in place. Instead of using a generic bullet object, I would like my platform player to replicate throwing a physics object (ie a grenade). I've tried a couple of different things and I feel like I'm close to nailing it but there's always something that I can't get down.

I tried just a simple "KEY IS DOWN: LEFT ARROW" and then adding force to the physics object. This looked great initially but once the player has let it fly and it's landed and settled on the ground, anytime the left key is pressed it will move again. It also means the player is forced to move if he wants to throw which is clumsy.

I can't really figure out a way to detect which direction the platform object is facing in order to use that as a guide point. There is "Compare Angle" but the platform object at the moment is just a single sprite box and even when I make a second sprite for the 180 angle it doesn't seem to make a difference.

Anyway I'm pretty stumped in regards to this now. If anybody has any suggestions I'd really appreciate it, thanks.
B
2
G
4
Posts: 22
Reputation: 1,094

Post » Wed Dec 10, 2008 6:34 am

For most things having a single box sprite like you do for your platforming object is best, but it's also good to know when to break the rules :)

If you make a 180 angle for your platform object, then you can detect which direction it's facing. Just make sure the hotspot and size of the sprite are exactly the same as your 0 angle. In fact, you can just copy the whole frame over by selecting the 0 angle's frame with C and then pasting it into the 180 angle's animation with V (not Ctrl-C and Ctrl-V for some reason :| ).

Also, are you intending to have player control over the actual thrown object, or do you want to just wind up and let it go do it's own thing? If you want it to behave more like an actual thrown object without any further input from the player then you'll need to gather all the speed/force/angle data that you'll need prior to spawning the grenade and once it's spawned the rest needs to be totally automated. The Ball behavior might work for you in this case. Set all of it's information in the same action that it's spawned in. That's all the amount of player input it should get from that point on.

I'd work up an example for you but I just reformatted my hard drive earlier so my computer doesn't have Construct on it yet :P
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Dec 10, 2008 10:28 am

Okay, here's that example:

http://willhostforfood.com/files3/6572650/balltoss.cap

Press Ctrl to spawn a ball. The ball's angle and speed is dependent on the direction and speed of the player at the time it's thrown. It uses the Ball behavior, and probably doesn't do exactly what you need but it should give you an idea where to go from there.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Dec 10, 2008 11:50 am

This helps a lot, thanks man.
B
2
G
4
Posts: 22
Reputation: 1,094


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest