How to optimize NPCs?

Grab your favourite IDE and tinker with the innards of game engines

How to optimize NPCs?

Postby nanoxax on Thu Apr 18, 2013 10:23 pm

I have a level that requires a lot of npcs walking around like a city. I do not know how to create this without lag and I assume that extra coding will be required to do this. I've tried every console command that I could find and I can't have over 40 npcs without a significant loss in fps. My computer can definitely handle this because I've done it in Garry's Mod and gotten 100 npcs without any loss in fps. They were all in motion also.

I'm running my mod with source 2007 and regular citizen models. When I toggle "+show_budget" the Client_Animation bar is full showing that the lag is caused by Client_Animation from the NPCs.

There might also be a way to optimize this in Hammer but I'm not sure of it right now.

Any help will be greatly appreciated.
nanoxax
Member
Member
 
Joined: Tue Oct 18, 2011 8:14 pm

Re: How to optimize NPCs?

Postby Major Banter on Fri Apr 19, 2013 12:14 am

The mod NMRiH has had a few issues with this, and while I can't tell you much about it (literally - I'm no coder) I know significant steps were made in reducing the CPU pressure caused by those animations. There is definitely a way to do it, but it won't reside in Hammer I'm afraid, end of story.
ImageImageImage
Major Banter
Veteran
Veteran
 
Joined: Tue Apr 01, 2008 10:52 pm
Location: UK

Re: How to optimize NPCs?

Postby stoopdapoop on Fri Apr 19, 2013 5:53 am

well, lets start from the very basics.

You assume there's extra coding involved, but do you have any programming experience? have you ever compiled source?

And I assume you're trying to do this for a mod, and not an existing game, as you can't run your own binaries with existing games.

This is just a shot in the dark, but I know that most NPC's use Inverse kinematics (IK) to line up the npc's feet with the ground, and speaking generally, this can be very expensive. Maybe there's a console command to allow you to disable the IK and maybe result in faster animations.
I'm Brown
Image
User avatar
stoopdapoop
Veteran
Veteran
 
Joined: Sun Aug 21, 2005 2:14 am
Location: Ann Arbor, MI

Re: How to optimize NPCs?

Postby ErikKiller on Fri Apr 19, 2013 6:22 am

I believe Valve stated that there's at most 30 NPCs on-screen in L4D games. So if even they are limiting them, then maybe you shouldn't push it?
Image
Image
First rodeo? Use the Source SDK Documentation for reference!
User avatar
ErikKiller
May Contain Skills
May Contain Skills
 
Joined: Sun Sep 09, 2007 4:05 pm
Location: Estonia

Re: How to optimize NPCs?

Postby zombie@computer on Fri Apr 19, 2013 8:05 am

if the npc's are just walking around you might be able to reduce the load in hammer by scripting generic npcs instead of their fully-functional counterparts. I doubt it'll help much in the animation load though, but you can always stop the npcs from moving once they leave the players' fov.
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: How to optimize NPCs?

Postby TechieUK on Fri Apr 19, 2013 2:07 pm

I remember a video of the mod Triage that had 80 rebels charging at a Helicopter. It said somewhere that they used "cheap" rebels, so maybe you could use lower poly versions of those characters?
Also know as WILLAM; TechieUK is my old name. If you see WILLAM on Steam or ModDB, it's me.
User avatar
TechieUK
Regular
Regular
 
Joined: Sat Apr 13, 2013 4:29 pm

Return to Programming

Who is online

Users browsing this forum: No registered users