Scripts / Unstuck NPC command

Author
Message
Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 7th Feb 2020 12:30
Hey guys,

So far, I made a script for enemies in my game (GG one was bugging and sometimes zombies just do nothing).

But in this script, it doesnt calc paths, just go straight to player. So, if a player run from a zombie for example, and quick hide behind a obstacle, zombie keep running look to the player position, and stuck in that obstacle.

What I need: When zombie stuck in obstacle (a command to check if enemie is stuck), then he do a small blink/jump ahead, maybe some animation of smoke appearing and a playsound.

My code is below:



3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 8th Feb 2020 09:01
I have never used it, but you may want to take a look at this thread.
Maybe you want to give a go.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Feb 2020 10:47 Edited at: 8th Feb 2020 10:50
that won't help if there's no obstacle avoidance in the code.
is there a reason you won't add the AI logic to your code? it is specifically made for the purpose of avoiding obstacles and the best option you have.
p.s. you can turn on the debug slider in tab-tab (slide it up rather than click it to make it work properly) to see the AI vision and path and any obstacle boxes.. it should help figure out your issue
otherwise you can;
1. add a short ray cast to check in front of the zombie - if ray cast hits an object he may be stuck
2. check how far the zombie moved in the last frame - if distance is too small he may be stuck (or at target location)

determining how far "ahead" to move to get past the obstacle is another problem, you can probably do it by just moving a fixed amount each time he is stuck and it should continue to detect the obstacle while he is inside it (but i'm not sure ray casts hit the inside).. otherwise you can keep ray casting till it hits open ground again.. or use amen's physicslib to work out the size of the obstacle (but i'm not sure it will be easy to take the angle of approach into account).
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 8th Feb 2020 14:37
Quote: "that won't help if there's no obstacle avoidance in the code."

Nice to know.

No easy to achieve but yours steps are the right ones.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
Medmatheus
Reviewed GameGuru on Steam
8
Years of Service
User Offline
Joined: 18th Oct 2015
Location:
Posted: 9th Feb 2020 14:31
I stopped working with GG script because if I use it in many zombies or in big maps, sometimes it just dont work ... zombies stand staring at the player.
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 9th Feb 2020 19:49
10-4
PM

Login to post a reply

Server time is: 2024-04-26 12:10:41
Your offset time is: 2024-04-26 12:10:41