Hot answers tagged

8

You are correct that it's not the View's job in an MVC architecture to implement any game mechanics like friendly fire. But whether it's the controller's job or the model's job to implement game mechanics is a matter of debate. There are basically two philosphies here: Thin Model In a thin model MVC architecture, the model is just a dumb data-structure ...


5

Your question is a good one. I've had exactly the same question regarding SpriteKit and have been very confused about the lack of information on the web about this. SpriteKit seems to encourage you to put all of your Model-View-Controller code into the same class (your SKScene subclass), which is really confusing to me. How would you ever build a game of ...


4

I'd warn against MVC for games in the first place, but putting said logic in the controller is fine. You can also put a small bit in the model if you want to be really pure. The Model contains a selection state and the Controller modifies this. Then the View uses this state to do its rendering. Something like: Model: bool selected = false Controller: ...


4

The correct way is to skip that frame and wait until the model is ready. If you find that the model update is taking too long, causing frames to be skipped too often, it's a better solution to optimize that instead of overcomplicating the code trying to be smart on the view side. A popular alternative is to use frame interpolation in the view, but it's not ...


2

The MVC pattern is indeed a good solution here. You would need three different controllers: The LocalPlayerController which is sending commands to a paddle by listening to the local input devices. When you have multiple input devices (keyboard, mouse, gamepad...) it might be a good idea to further subclass it into the one it listens to. In any case, these ...


2

The suggestion of using arbitrary distance units is a very good one, and once it really clicks, you'll see that floating point vs fixed point is only a matter of how you represent your numbers. Using only fixed point is of course the most accurate solution, but floating point inaccuracies start to show mainly when you, for instance, exchange floats between ...


2

I'm not sure that it is possible to keep a good communication speed over time with a growing community. You have limited control over this. The problem is that I can't allow a communication to be longer than 200 ms (time of the client side animation). On the server side I have to go to the database to do the validation. 100 ms ping is short enough ...


2

Unless you're making a game like solitaire or minesweeper, the design pattern that games typically use is called the game loop. Read Inputs Update State Draw Go to 1. You can see that it has similarities to MVC, but there are some differences. MVC typically does all 3 steps per action. The game loop takes all actions then does all updates then draws ...


2

In a classic MVC world, the networking is split into a controller and a view component. Network input is a controller, because it processes commands which then result in changes to the model. The network output is a view, because it translates the model changes which are happening in your game into a network protocol. This is not much different from ...


1

I generally prefer ScriptableObjects for storing data that: You want to be editable with a GUI in the Unity Editor (as they can be edited in the Inspector much like the components on a GameObject) Is determined at design time and will not change at runtime You want to be able to assign to fields in the Unity Inspector Here's the typical strategy I'll use ...


1

tl'dr Design Pattern can show you a solution, how this pattern helped many others. If it is suitable for your problem is only known by you. Design Patterns are rather independent of applied technologies (LIBGDX). Details: MVC is a Design Patter that evolved from the UI-Design-Problems in the late 70s. What you are trying to explain looks to me like you're ...


1

You need to IEnumerator to yield return and wait for request to complete. Call this method inside coroutine. Method: public IEnumerator GetLeaderBoard() { UnityWebRequest myWr = UnityWebRequest.Get("http://your-url")); yield return myWr.SendWebRequest(); if (myWr.isNetworkError || myWr.isHttpError) { Debug.Log(myWr.error); ...


1

In simple terms a common design in SpriteKit games is scenes, layers, nodes and child nodes. You might make each part into a discrete class that encapsulates all of the parts, properties and methods. For example a Background class that has layered images, particles, various properties like the speed each layer should move and public methods to start and ...


1

I thought I would share my resolution with you here. I tried a variety of things, including lengthy web.config changes per recommendations on Unity's site, and others found in other forums, but the only thing I ended up needing to add was the following code to my Startup.cs file in the Configure() method: StaticFileOptions option = new StaticFileOptions(); ...


1

Your lecturer is teaching you best practices through software design patterns - in this case, The Strategy Pattern (known in simpler languages like C as function pointers). You can follow your lecturer's guidelines AND be elegant / efficient at the same time: enum EffectType { EXPLODE, GAIN_HEALTH, LOSE_SCORE } public interface Effect //strategy ...


1

The two are not mutually exclusive. It's a reasonable approach as long as your comfortable working that way. I assume when you say pure C# you're still using MeshRenderer components, gameObjects, etc. I've worked this way before in Unity, especially early on as I came from Objective C and had written a bespoke 2D Sprite system, and instinctively wanted to ...


1

Separating model from view and controller is invaluable in one very specific aspect of game development often overlooked when not developing at scale: testing. Develop your game simulation as a model, and you can swap out a user input device controller for an automated, repeatable testing harness. This allows for incredible leaps forward in testability, ...


1

First, a quick review of MVC as it pertains to OOP: Model - objects that store and maintain data consistency with respect to the problem at hand, in our case simulation. View - objects that translate output to the user. Controller - objects that translate input into commands that alter the model. In its purest form, we should be able to save a game's state ...


1

Sounds like semantic noodling to me. I guess I tend more towards your option 2 in that I have lots of different model objects for different aspects of the game instead of just one monolithic model object that handles everything, but I don't keep "menu" and "game" areas strictly separate. After all, what if you want to be able to access the main menu every ...


1

A Singleplayer game is a Multiplayer game with one human player. None-human players (often referred to as bots or AI), are a class or a group of classes that extends the base Player class. These classes compute the game state and output the moves the computer algorithm "considers" to be reasonable. You could implement Multiplayer by itself and allow a ...


1

It's a bad idea if you are talking about 3D / GPU rendering. It's fine if you're rendering 2D / non-GPU, as it may make more sense to you organisationally. The reason is that GPU rendering, for optimal (or even reasonable) performance, requires individual render passes that render groups of game objects with similar properties i.e. materials, since each ...


Only top voted, non community-wiki answers of a minimum length are eligible