• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
bernatripoll

Mob/NPC's AI in a MMO with Unity + Custom Server

3 posts in this topic

've created a basic MMO system using Unity3d and a custom c# server. Right now, players can walk and attack eachother and it works great!

Now, I'm implementing the mobs system and I'm not sure how to do it, here's my thoughts!

Spawning

  • The server spawns the mobs on the world based on a % (This works great)

  • Then, players can see the mob fixed on the position where the server spawned it.

Moving mobs

  • I'm not sure how to do this, I've thought about 2 options

    A) The server changes the position of each mob every X seconds (say 3-4) and sends the new position to all the players around, then each player starts moving the mob towards that position. I know this would cause that different players sometimes see the mob on different locations...

    B) Every 3 or 4 seconds (same) the server sets a new final position for the mob, and every 0.5s (server sends sync snapshots every 0.5s), sends the mob position to all players around. This seems a better solution but there's gonna be so many packets travelling around...

Mobs Attack Players

  • Using the option B) for moving mobs around, the server could detect when one player P is close enough to the mob M, so M should start attacking P.

  • But here's the big question the server doesn't know ANYTHING about the terrain so, now M have to go towards P to 'kill him', but the server can't do the pathfinding algorithm to move M to P's position... So I came with an idea!

Idea!

  • When the server sets M to attack P, then P gets the control of M so the player starts controlling the mob and makes it go towards him using the pathfinding algorithms of unity! Then, the player every 0.5s is going to send his position and M's position to the server, and the server updates M's position exactly where P said it has to be.

  • When the server detects that M is close enough to P to attack, M causes damage to P even if he's still running away and M is going after him.

What do you think? Would it work? Any better solution? Thanks :)

0

Share this post


Link to post
Share on other sites

I'm currently doing a similar thing (online rpg kind of game) and i came to the conclusion that, atleast for me, it seems inevitable to have the server not be a Unity instance too, if i want to handle physics server sided. I'm also using Aron Granbergs A* for pathing and skills/spells (teleporting for example, like guild wars 2). I read somewhere that he planned the possibility of it to be run outside unity (Photon i believe), but haven't seen any further mention of that.

But for now it works very well inside unity. i send position related data (position, velocity, y-rotation) 5 times a second and the difference on the client is very acceptable (interpolated and halfway extrapolated).

 

Also, dont let the player control any mob. I have once seen a game doing that where you could pull all mobs in the area towards you using a hack and one-hit kill them.

If unsure maybe just do the movement (mob to player) in a straight line (some Wow private servers do that, if pathing is not enabled). The Mob will most likely run through walls and all that but thats better than giving the player an opportunity to cheat for free.

Edited by Valoo
0

Share this post


Link to post
Share on other sites

the server doesn't know ANYTHING about the terrain


You likely need to fix this.

There are a few ways to do this. For example:
- You could run the same physics on client and server
- You could pre-process the game level to generate a simplified "walkable mesh" for where the monster can be/see and run a different physics simulation on the server
- You could give each monster a "must not leave area" defined by a rectangle or polygon, and it just stays in that area, and have artists define this area for each monster, and make sure there are no walls in that area
1

Share this post


Link to post
Share on other sites

 

 

Idea!

  • When the server sets M to attack P, then P gets the control of M so the player starts controlling the mob and makes it go towards him using the pathfinding algorithms of unity! Then, the player every 0.5s is going to send his position and M's position to the server, and the server updates M's position exactly where P said it has to be.

  • When the server detects that M is close enough to P to attack, M causes damage to P even if he's still running away and M is going after him.

What do you think? Would it work? Any better solution? Thanks smile.png

 

 

The danger there is that you just handed M off to P, and the client is untrustworthy, and could be telling the mob to do whatever it wants the mob to do -- like go towards other players, or stand still while getting attacked at range.   I think in the long run, you're really going to want the server to have some idea of the terrain.  It doesn't need everything, and should probably get by with just the underlying navmesh.  (or grid, or whatever you're navigational representation is)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0