• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By davemacdo
      I'm a formally trained composer (doctorate from Michigan State) who writes what most people would call avant-garde concert music. I love weird abstract projects, and I would like to work with somebody making a weird, abstract, artsy game. 
      You can find more about me and my music on my site. I have worked with acoustic and electronic sounds, including some procedurally generated and interactive computer music. 
      In particular, I would like to work on a project that lets me use Fmod to prepare an adaptive score for a game built on Unity or Unreal. I've been a music professor and would like to get experience working in this medium so that I can be a better mentor for my students. Send me a DM or email <davidjohnmacdonald@gmail.com> if you would like to discuss working on a project together. 
    • By Tuner_z

      Name: One Level: Stickman Jailbreak
      Price: Free
      Developer: RTU Studio
      Platform: Android
      Language: C# (Unity3D)
      Google Play: https://play.google.com/store/apps/details?id=com.RTU.OneLevel
       
      Hello!
      I want to show you my game! "One level: Stickman Jailbreak" is a puzzle game with unusual gameplay where you must help the character to escape from prison. You just need to take the key and get out alive. The game has only one level, and there are many ways to complete it. Not everything is as simple as it might seem at first glance, so there are clues in the game.
       
      Short description:
      Nobody escapes from here!
       
      Description:
      Tommy got into trouble again! Our hero is behind bars. But he's not going to stay in jail for a long time and he decides to escape. Tommy steals a key and gets out of the jail cell. But our friend doesn't go free: Tommy suddenly finds himself in the same room from which he just escaped! The conditions for escaping change every time. In order to go free Tommy will have to solve logical puzzles and you can help him in this!
      At first it will be easy, but the tension will increase, and the tasks will become more complicated with each level. You should use your brain for all 100%, but if your skill is not enough, you can use a hint or ask for help from friends!
      You can solve the puzzles alone or with your friends and spend time well!
       
      Features: 
      Features:
      - 48 unique levels;
      - the game is translated into 10 languages: English, French, German, Spanish, Italian, Portuguese, Russian, Japanese, Chinese, Korean;
      - the function of "help from friend";
      - hints;
      - instructions.
       
      Trailer:
       
      Screenshots:





       
    • By Brandon Marx
      Hello forum,
      I have some decent amount of experience in Unity making games for Software Engineering projects in college, these were very specific projects however and I still am fairly new to building games. I wanted to make a game that uses the shadows of objects for collision detecting (i.e. shooting a gun at a characters shadow causes that character damage. What is the best engine to do this in (game will be 3D), and does anyone have any advice on how to approach this concept? I consider myself fairly experienced in programming, but game dev is just an entirely different beast.
    • By juicyz
      Hey all,
      I've been slowly working on my game called AotW for a while now.  I have come to the conclusions that it would be nice to cooperate with 1 or 2 others to help finish it.  Ive been trying to keep my GDD up to date with my ideas and development so that would give a better overview of the game when the time comes.  Currently I have a basic skeleton of the RPG elements needed but everything can still be discussed and talked about and we can transform my idea to something the group likes.
      The premise of the game is a Diablo-like procedurally generated map with RPG elements that include sockets, inventory, classes, abilities, crafting, loot, items, sockets, and enchanting.  This will be done in a 2D iso view as I can't do 3D art and I enjoy 2D games a lot.
       
      I don't plan on releasing this as this is more of a hobby project for me and I have a full-time job.  Though I'd like to start putting more hours into development and having others definitely will be motivation.  I also want to be able to say I have finally "finished" a game idea to some degree.  If the time comes and we want to release it, then we can go ahead and do so but that's not my purpose or plan. 
       
      Discord:
      Juicyz#3683
       
       
      Thanks,
      Juicyz
    • By Arnold // Golden Donkey Productions
      Hi, I've been working on this issue for a while and haven't yet found an answer.
      Does anyone know the best way to convert unity's LAT & LONG into a vector 3 position that I could use in a virtual world (if it's even possible). 
      Thankyou in advance
  • Advertisement
  • Advertisement
Sign in to follow this  

Unity Thread timing

This topic is 4576 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my game I've got two threads, a server thread and a client thread. The server thread does all the logic and collision stuff, the client mostly renders. The trouble I'm having is getting the two threads to share the CPU. The client runs in the main thread and the server runs in a thread I create. I'm using SDL_Delay() in the server thread to make it give up the CPU sort of like this:
// calculate how long the delay should be to get the
// thread to run around 100 Hz
delay = 10 - (SDL_GetTicks() - timeAtBeginningOfFrame);
if (delay > 0) SDL_Delay(delay);
Later in that thread I'm using fixed timesteps in ODE, like this:
Step()
{
     remainder += SecondsPerFrame();

     while(true)
     {
          if (remainder >= 0.01) // 100 Hz
          {
               dWorldQuickStep(world, 0.01);
               remainder -= 0.01;
          }
          else { break; }
     }
}
The problem is when the program first starts out it's running at 100% CPU usage, and it's slow. The client thread is running at about 50 FPS and the server at about 40 FPS. But the wierd thing is if I click and drag on the game's title bar, pausing the client thread, then release it, when it starts running again the client is running at around 100 FPS and the server at about 90 FPS. What is going on?

Share this post


Link to post
Share on other sites
Advertisement
No one?

Let me present the problem like this. There's the server thread and the client thread. I don't really care how fast the client thread runs (other than as fast as possible), but the server, for best results, should run somewhere between 70 and 100 FPS. The way it is now the speed of the two threads seem to be dependent upon how fast the other thread is running. When the client thread is busy drawing lots of stuff on screen and the framerate drops, the framerate of the server thread also drops. When the client isn't drawing much at all the framerate of the server thread goes up. But what I want is the server thread framerate to be more or less constant.

How do I do it?

Share this post


Link to post
Share on other sites
You could lock them together and dispatch the thread. The server keeps track of it's frame rate and decides when to allow the client to execute. You can place multiple points in the client where it enqueues upon a shared object to allow the server to let it run for less than a full frame. The server should track the client's framerate so you don't starve the client for CPU.

Share this post


Link to post
Share on other sites
You need to give the server thread a higher priority. That way it always runs when it is ready, and the client thread only runs when the server thread is waiting -- or something like that. Careful... setting thread priorities can lead to problems. For example, if the server thread is always busy, then the client thread may never run and thus never receive windows messages -- or something like that.

Share this post


Link to post
Share on other sites
Trying to fix race conditions by changing thread priority is a dangerous strategy.

The best way to solve such problems is to implement thread synchronization by signalling the client to go into a waitstate (this way it doesn't consume (too much) CPU time) and make it wait for the server to respond (another signal) or a time-out.

cheers

Share this post


Link to post
Share on other sites
So basically the server controls when the client is able to run? Wouldn't you get the same result from the server and client running in the same thread, and the server calling client.Run() occasionally?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by BradDaBug
So basically the server controls when the client is able to run? Wouldn't you get the same result from the server and client running in the same thread, and the server calling client.Run() occasionally?


The short answer: yes.

Share this post


Link to post
Share on other sites
Not exactly. The code that passes control back to the server can be anywhere in the client thread and the client can resume exactly where it left off when the server passes control back. That's a little hard to manage in a single thread.

Share this post


Link to post
Share on other sites
Plus: by using a signal that isn't tied to the combination of server/client, you can pretty much signal any client/server. In your solution the server has to know (too much) about the client whereas using a signal would give you a more loosly coupled system.

Cheers

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement