The Daily Click ::. Forums ::. Klik Coding Help ::. Enemy movement
 

Post Reply  Post Oekaki 
 

Posted By Message

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
29th April, 2007 at 02:50:27 -

For my enemies (on a 16x16 grid), they each have 4 detectors on each side of them. I can get them to move 16 pixels in a random direction but I can't get them to avoid hitting an obstacle, they end walking on top of obstacle blocks. Although it works well with 1 enemy.
I don't know what to do. :/

 
lol

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
29th April, 2007 at 03:08:34 -

If they are all the same object, and just one is colliding, then it's most likely that you'll need to do this:

You will need to spread a value in your object to give them all a unique id.
Then you will need to do a fastloop through each one (do this by comparing loopindex with id value).
Then you can tell the code to run on each enemy.

Hope that helps

 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
29th April, 2007 at 03:43:57 -

yeah I've done that to give them all detectors, but I can't them to work when it comes to detecting.

 
lol

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
29th April, 2007 at 04:04:48 -

* Always
- TopDetector: Spread value 0 in alterable value A
- Enemy: Spread value 0 in alterable value A

* Always
- Start loop "foo" NObjects("enemy") times

* On loop "foo"
* TopDetector: Value A == LoopIndex("foo")
* Enemy: Value A == LoopIndex("foo")
- TopDetector: Set position to (0,0) from Enemy

* On loop "foo"
* TopDetector: Value A == LoopIndex("foo")
* Enemy: Value A == LoopIndex("foo")
* Direction of Enemy is (Up)
* (Negate) TopDetector is overlapping backdrop
- [move enemy]

Repeat for all other directions/detectors.

Image Edited by the Author.

 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
29th April, 2007 at 04:53:22 -

I realised it was something else >__>
cause I was already doing what you said Axel, thanks anyway

 
lol
   

Post Reply



 



Advertisement

Worth A Click