NPC Movement Problem - Moving only one direction

For questions about using Classic.

Post » Sun Dec 26, 2010 9:58 pm

I am not very good with AI to start with, but I decided to give it a ago. I am trying to program a zombie like thing to be a "Generic Troll" for my game "The Digital Expedition". He only moves one direction relative to the player and not both.

Here is what I am talking about:



What exactly am I doing wrong? I bet its something really simple, too. >_<

(Also, it is no longer "Orange Block", that's just what I named it for testing.)
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Sun Dec 26, 2010 11:30 pm

You can use overlap at offset, just use positive and negative values.
>troll is overlapping player at offset x 10
>-troll set x to .x+1
>troll is overlapping player at offset x -10
>-troll set x to .x-1
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Mon Dec 27, 2010 4:12 am

This is what the event sheet looks like now:



The Zombie moves and stuff, but he kinda glitches out at some point

Here's a cap: http://www.mediafire.com/?t4yj0qpp4aimxet

First one to solve this gets a cookie. :)
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Mon Dec 27, 2010 7:27 am

Distance gets you the x, and the y, offset gets you the x, or the y.
You should just use one for your detection.
Also the way you have it set up your saying if the distance is greater than 300, or the distance is less than 300 then move, but that will make the troll move all the time, and distance() doesn't care if the player is to the left or to the right.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Mon Dec 27, 2010 10:07 pm

[quote="newt":2ytj1tkv]Distance gets you the x, and the y, offset gets you the x, or the y.
You should just use one for your detection.
Also the way you have it set up your saying if the distance is greater than 300, or the distance is less than 300 then move, but that will make the troll move all the time, and distance() doesn't care if the player is to the left or to the right.[/quote:2ytj1tkv]

The reason I had the distances there was so that he would only go after me if I get close to him.

If it is going to cause problems, how else could I do it without distance(x1,y1,x2,y2)?
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Mon Dec 27, 2010 11:16 pm

Like I said in the first post.
[url:fzwxadly]http://dl.dropbox.com/u/666516/offsetplat.cap[/url:fzwxadly]

Offset works well for is left and is right, you just have to get your movement correct, or add additional offset comparisons for the gap made when the troll moves.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Tue Dec 28, 2010 1:50 pm

[quote="newt":15qbily2]Like I said in the first post.
[url:15qbily2]http://dl.dropbox.com/u/666516/offsetplat.cap[/url:15qbily2]

Offset works well for is left and is right, you just have to get your movement correct, or add additional offset comparisons for the gap made when the troll moves.[/quote:15qbily2]

WAAAAH! WHY DOESN'T IT WORK!?

Take a look for yourself: [url:15qbily2]http://www.mediafire.com/?ar0hhprqscyhhwn[/url:15qbily2]
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Tue Dec 28, 2010 2:34 pm

Your mixing platform with custom movement, and your own custom movements. They just don't mix well.
I'd suggest, until your more familiar with everything, that you use one behavior for your movements.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Tue Dec 28, 2010 2:47 pm

[quote="newt":1gmwh9pb]Your mixing platform with custom movement...[/quote:1gmwh9pb]

Erm, the zombie HAD a platform behavior, but I removed it before even making this thread...

A bug, perhaps?

Anyways, I am going to make the object from scratch. That way, it should work right, and stuff...
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Tue Dec 28, 2010 11:50 pm

Alright, I got him to move and stuff, but he only moves when I collide with it, which means he will just charge at me. I think this would be a cool thing to do instead of slowly trudging along.

Also, a tad off-topic, but I noticed when I explode exactly 58 grenades, the plug-in crashes, which stops my game. It doesn't have to be at the same time either, just when I reach grenade #58.

When I DO overload the game with grenades- *PC Blacks out* *Does Cold-Shutdown*

...

...

OK, back. Anyways, If I do overload the grenades (Throw them consistently), and reach 50 something grenades exploded, the game crashes, saying that a error was caused by the player_arms object. Which is weird, considering it has almost nothing to do with the grenades. Is this a plug-in bug or am I doing something wrong?

The cap in my above post contains the same conditions for grenade-throwing functions.
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests