Turret Sprite Sheet

Get help using Construct 2

Post » Fri Apr 26, 2013 3:00 pm

Yes, I've actually made some progress since yesterday thanks to BluePhaze's tips. I don't think I used the best method, but I actually got it working and not with TOO many events.

Keep in mind I'm using Construct Classic, not Construct2, so my angles and stuff may be different than yours. But basically what I did was make sure the angle is being checked whenever the turret is moving, or not moving, and then I assigned animations to every possible angle. Here's how:

Turret - Is moving
    Turret: Angle >= 61
    Turret: Angle <= 119     Turret: Set animation to "Down"

    Turret: Angle >= 120
    Turret: Angle <= 150     Turret: Set animation to "DownLeft"


    Turret: Angle >= 151
    Turret: Angle <= 209     Turret: Set animation to "Left"

And so forth until I'd covered all possible angles. Then I repeated for when the turret's not moving, and it seems to be working ok so far.
This is the link to what I've got: http://ppl.ug/gZdoYdSJfxc/. The turret is the player, you control it with up, down, left, and right. Press "e" to make it acquire target and fire. It should automatically rotate, with animations, towards the "enemies" (red x's).

But now I'm wondering if I can get some more help. As you can see from my example, I want the player to control the turret. And I want it to aim at enemies and fire, using the animations which I've provided, which seems to be working. However, I want the turret to stay angled towards the target, even when the player is moving the turret. For example, in top down shooters where you control where the player points using the mouse, but he can move freely without aiming all over the place. I want to accomplish that, but with the turret automatically finding targets and keeping aimed at them while the player moves. Any ideas?SirAwesomeface2013-04-26 15:07:31
B
2
Posts: 4
Reputation: 158

Post » Fri Apr 26, 2013 3:01 pm

Sorry I don't know if the link worked in the last post. Let's try agian. Here http://ppl.ug/gZdoYdSJfxc/

EDIT:
Nevermind, ignore that. I can't post links yet, apparently. You'll just have to copy/paste ;)SirAwesomeface2013-04-26 15:02:26
B
2
Posts: 4
Reputation: 158

Post » Fri Apr 26, 2013 4:15 pm

@sirawesomeface Great name by the way!

I have not looked at your example, but something like this should work.

If you have a reticule sprite use that and have it position itself on to say the nearest enemy to your tank.

then simply have the turret set its angle to the reticule.

Enemy dies have the reticule set itself to the next nearest enemy...Pixel perfick2013-04-26 16:27:40
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Fri Apr 26, 2013 5:59 pm

I'm using Construct 2, and the problem that I'm facing is that the sprites (and animations) are kinda isometric... so, the handle of the angle is somehow tricky... what I was trying yesterday was to have an invisible circle as the turret, and the isometric sprite pinned to the "turret", get the angle of the tower and compare it to the angle of the aniamtion in order to detect if the animation should go clockwise or counter clockwise... But it didn't work.


I'll try something different today, and update here if got something useful.
B
7
S
1
Posts: 17
Reputation: 585

Post » Fri Apr 26, 2013 6:05 pm

@Welfo , at the place of rotating the object himself ... create an object called *Object-Name*_Angle and put it in a container ...

Then , add all the events related to the rotation in a such way that the object doesn't have anything and is only an animation ...

Then , follow sirthingyIdontrememberhisname's tip , don't forget to assign those events to Object_Angle ...
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Mon Aug 05, 2013 6:34 pm

I was searching for an answer to the isometric problem myself for a while. I'm not sure if this is exactly what you guys were trying to explain above, but I thought I'd post my solution:

capx file

Try it

I made a simple turret in blender and saved png renders at every 45 degrees to create my animation frames for a total of 8 frames. Note that it would probably look a lot smoother compared to my exmaple saved every 22.5 degrees for 16 frames.

I then created a sprite with turret behaviour to act as a place holder to acquire and generate my angle towards the target. I created another sprite to hold my turret animation frames and created an image point at the end of the cannon in each frame. You'll want to place them into a container.

I created 8 events checking the angle of the turret sprite corresponding to 22.5 degrees before and after my turret angle and actions to change the turret animation to the correct frame as seen below.

I then simply spawn a bullet from the animation (image point 1 created earlier) rather than the turret whenever the turret is able to shoot.

B
7
S
3
G
3
Posts: 22
Reputation: 2,385

Previous

Return to How do I....?

Who is online

Users browsing this forum: Radulepy and 6 guests