How Do I Code AI For Level Elements?

Get help using Construct 2

Post » Sun Oct 18, 2015 7:50 pm

Hi Guys,

I am looking for a little bit of help in regards to coding the logic of some level elements.

I have started to bring in some elements to my game to test some idea's and I am struggling on how to code them and give them functionality.

I have a saw in my game which is an obstacle the player must dodge and not get hit by. The saw is something I want to move up, down, left and right. I have seen some tutorials which use sprites as boundaries in order to keep the AI in specific area's. I have a simple set up at the moment here is a screenshot.

Image

The saw for this section of my game I want to move up and down, but I have other sections where I want the saw to move horizontally as well. I did get the saw moving horizontally through a simple event which basically stated

if the saw is > 0, set y position, 415.

This got my saw in the correct position and with the platformer behavior I simulated left and right movement through a global variable called 'Patrol' (0 was left and 1 was right). I don't know if this is the best way but it did work as I wanted in regards to the movement of the saw my only problem was I was unable to get the saw moving vertically when I wanted. I was thinking of using separate event sheets but then I thought that just complicated things and wouldn't really be the best solution to how I want to use the saw throughout my game.

I guess what I am asking here is, would it be possible to have an object move on its own in multiple directions? I am struggling to work out the logic and what behaviors to use.

Cheers,

Dave.
B
9
S
3
Posts: 45
Reputation: 770

Post » Sun Oct 18, 2015 7:59 pm

I guess you could use any movement behaviour..

In this case using the sine behaviour might suit you best, but depending on the amount of difficulty of the movement others might be better..

You might also want to take a look at the third party plugins "litetween" and "moveto"
They can make certain movements easier..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: JaredX, ksiads, Magistross, Rable and 6 guests