How do I make an AI that can make a slingshot?

Get help using Construct 2

Post » Thu May 12, 2016 11:14 pm

Hello guys,

I'm developing a game based on a slingshot. You play against an AI in a turn-based game.

I don't have a problem to develop the slingshot action and also to change the turn after 5 seconds of each player action.

My problem is related on the slingshot because it is based on the touch event. It's work fine for the player. However, I can't figure out how to make the AI do the slingshot because It can't use touch.

I also want to be able to make the AI aim a target before the shot.

The game's mechanics is quite simple at this phase of development. The player should click on "red square base" and then click on the button "go". The green object that represents "the player" will be positioned on "red square base" whereby to drag and release the slingshot action will be done. The yellow dashed line is your aim. After 5 seconds the turn changes and the AI should do the same action, but by the "blue square base" in order of hit the target by throwing the orange object, that represents Ai player.

Follow bellow the screenshot of my eventsheet and also the game. The capx is also there.

Image

https://drive.google.com/open?id=0B2tOQE13wmHCQTBzNFpDenFiNUE

https://drive.google.com/open?id=0B2tOQE13wmHCZk1xYzZrZnc2VG8

Does anyone can help me? I appreciate any help of you guys! :D
B
4
S
1
Posts: 2
Reputation: 300

Post » Fri May 13, 2016 11:39 am

For AI in this case, you just have to "fake" the visual. I'm on mobile so I don't know how do you do your event sheets. But what I would do is separate the events into 2 parts. One would take in the player's input and the other would be automated events to give the player an impression of AI.

You could try copy and paste all the player's events but change all player's input to be, for example, some other variables instead. Then, make it so when it is the AI's turn, you update these variables with respect to your game's rule and give an impression of AI to the player.

This is the gist of what you have to do, but I couldn't say much on the technical implementation. This all depends on your event sheet design.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Fri May 13, 2016 5:58 pm

TwinBlazar wrote:For AI in this case, you just have to "fake" the visual. I'm on mobile so I don't know how do you do your event sheets. But what I would do is separate the events into 2 parts. One would take in the player's input and the other would be automated events to give the player an impression of AI.

You could try copy and paste all the player's events but change all player's input to be, for example, some other variables instead. Then, make it so when it is the AI's turn, you update these variables with respect to your game's rule and give an impression of AI to the player.

This is the gist of what you have to do, but I couldn't say much on the technical implementation. This all depends on your event sheet design.


It's exactly what I'm trying to do. I really copied the player event and create the AI event base on it, but changing the value of the variables. I can't figure out a way to replace the touch movement in order of doing the slingshot action because the touch is the real trigger for this action as you can see bellow.

In Construct2 I use the player action Set angle to angle(Touch.X,Touch.Y,base1.X,base1.Y) and also move at angle [ angle: Self.Angle+180 ; distance: min(distance(Touch.X,Touch.Y,base1.X,base1.Y)/3,45) ] while the object is in touch and aiming. Finally I use apply impulse at angle[impulse:distance(Self.X,Self.Y,base1.X,base1.Y)/4.5 ; angle: Self.Angle ; Image Point: 0 ] to be done on any touch end to launch the object.

The main problem is how to "fake" the visual like you said. I imagine that I need make the AI object aim the point he wants to hit and then move a little in the opposite direction "faking" the drag movement that creates the impulsion. After it, I need to launch it towards the aimed direction with a properly force and angle. However, the force and angle in the true slingshot depend on how far you drag it before release.


So, It will give me another problem like how can I "fake" it for appears to be a real simulation? If I can't do it, it will give the awful impression that doesn't matter the distance dragged before releasing the object, the force will be always the same.

Thanks for your reply :D
B
4
S
1
Posts: 2
Reputation: 300


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, brunopalermo and 29 guests