Complicated Question???

Get help using Construct 2

Post » Sat Jul 14, 2012 12:41 am

If i had an object with a bullet action on it how could i tell it to not go through a wall without collision? In a pacman example the ghost never collided with the walls, instead a script allows them to pick on available directions. For my game i want my object to go in a specific path without AI. I only want my object to change directions when it reaches a wall.

B
22
S
5
G
3
Posts: 194
Reputation: 5,855

Post » Sat Jul 14, 2012 1:00 am

You could just tell it to rotate on collision with an invisible object, so it never actually touches a wall, you could set angles of 0,90,180,270 and get it to either pick one at random, but this could create a bounce action, or get it to check for invisible object is within say 2 pixles then rotate.
B
40
S
14
G
11
Posts: 243
Reputation: 9,432

Post » Sat Jul 14, 2012 6:34 am

you can save the X and Y position of your object each tick in two private variables, and then
if there's overlapping
-> fall back the the previous position
-> then randomly pick any of the 3 cardinal directions your object wasn't moving toward (loop three or four times)
   -> check each time if you won't run into a wall again (overlap at offset)
   -> and then apply and break the loopYann2012-07-14 06:35:33
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Jul 15, 2012 1:56 am

Thanks yann here is the capx.

http://dl.dropbox.com/u/11360597/DirectXMainFile.capx

i called it directx because you direct the critters around the map.


You press space to start them going. Maybe this will better help explain my dilemma. If i can get this to work i will be extremely happy. If i can't get it to work i will scrap the project altogether.

B
22
S
5
G
3
Posts: 194
Reputation: 5,855

Post » Sun Jul 15, 2012 2:00 am

going all through the walls like crazy, its so annoying.
B
22
S
5
G
3
Posts: 194
Reputation: 5,855

Post » Sun Jul 15, 2012 4:31 am

easier with a grid movement type of algo botAI.capx

you can even set the speed super high like 10,000 px per second, you won't lose any bot :D
Last edited by Yann on Sun Sep 14, 2014 9:08 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Jul 15, 2012 5:56 am

holy crap, thanks dude. The only thing is i don't want the bot to have a choice to go in any direction i want them to be stuck in a loop on purpose. I want the player to place an arrow to get the bot to exit the loop. They are 2 smart hehe. I want them to be dumber if that makes any since XD.

Here is a youtube link of what im trying to go for.

http://www.youtube.com/watch?v=cmv6D-BJtSk
B
22
S
5
G
3
Posts: 194
Reputation: 5,855

Post » Sun Jul 15, 2012 1:09 pm

if you understand the code, it's just one line to change
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Jul 15, 2012 7:12 pm

is it in the check for walls part? I need a hint lol.
B
22
S
5
G
3
Posts: 194
Reputation: 5,855

Post » Sun Jul 15, 2012 7:17 pm

i changed the set dir to chosen (-1,-1) and there sort of looping, but some of them want to escape the loop by going in a forbidden direction.
B
22
S
5
G
3
Posts: 194
Reputation: 5,855

Next

Return to How do I....?

Who is online

Users browsing this forum: Matthew de, onzephyr and 0 guests