Advertisement

AI class problem (EVERYONE moves the same!!!!)

Started by July 27, 2010 01:09 PM
12 comments, last by dpadam450 14 years, 3 months ago
thanks you, it is fixed.

when I delete static variable and change to normal member.
It works perfect.

But, I don't understand why??
Can somebody explain to me?

and thanks for all posts.
I have learned a new thing.

Quote: Original post by fantasyme
thanks you, it is fixed.

when I delete static variable and change to normal member.
It works perfect.

But, I don't understand why??
Can somebody explain to me?

and thanks for all posts.
I have learned a new thing.


If you make the variables static, their values are shared by all instances of the class. So if one instance assigns, for example, "bTurnRight = True", this is now the value that all of the other instances will see.
Advertisement
I figured it was something like that. When everyone is acting the same at the same instant when only one of them is supposed to be changing, it is usually a coding error like that.

FYI, tracing your own code execution like I suggested would have caught that.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Every time is hits that function, it uses that static variable. So if your first guy calls that function and rotation = 30, the next guy calls move and rotation = 30. Your using the same variable for everybody. Its 30 for everybody.

NBA2K, Madden, Maneater, Killing Floor, Sims

This topic is closed to new replies.

Advertisement