Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

askthedev.com Logo askthedev.com Logo
Sign InSign Up

askthedev.com

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Questions
  • Learn Something
What's your question?
  • Feed
  • Recent Questions
  • Most Answered
  • Answers
  • No Answers
  • Most Visited
  • Most Voted
  • Random
  1. Asked: May 6, 2025

    How can I fix laggy physics when lerping Time.timeScale and ensure consistent performance in built versions?

    anonymous user
    Added an answer on May 6, 2025 at 4:14 pm

    Time Scaling Issues in Unity It sounds like you're running into some common issues with time scaling in Unity, especially when it comes to physics. When you change Time.timeScale, it doesn't automatically adjust everything related to physics, which can lead to the laggy behavior you're experiencing.Read more

    Time Scaling Issues in Unity

    It sounds like you’re running into some common issues with time scaling in Unity, especially when it comes to physics. When you change Time.timeScale, it doesn’t automatically adjust everything related to physics, which can lead to the laggy behavior you’re experiencing. The key things to consider here are Time.fixedDeltaTime and how physics updates are managed.

    First off, your line:

    Time.fixedDeltaTime = Time.unscaledDeltaTime * Time.timeScale / startTimeScale;

    This line can cause issues if Time.timeScale goes below 1.0 because unscaledDeltaTime does not account for the change in time flow, leading to inconsistent physics calculations. Instead, try this approach:

    Time.fixedDeltaTime = 0.02f * Time.timeScale; // 0.02f is the default fixedDeltaTime

    This keeps things simpler. It sets your fixed delta time in proportion to the normal time scale, which should help with how physics behave when time scales change.

    Also, if you’re interpolating time with an animation curve, make sure that your transitions are smooth and that you’re updating the physics calculations accordingly. You might want to consider adjusting your time scale gradually rather than instantly to help maintain a more stable experience.

    You might also want to implement a system where you can visually debug how the time scale is affecting your game objects. This can help you to visualize any potential issues that arise during gameplay.

    Remember, debugging time scaling issues can be tricky, so take your time testing different approaches, and tweak your settings until you find something that feels good in both the editor and standalone builds.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  2. Asked: May 6, 2025

    What is the best strategy for loading and releasing lightmaps in Unity using Addressables for an efficient memory management system?

    anonymous user
    Added an answer on May 6, 2025 at 2:14 pm

    Optimizing Lightmaps for Your Mobile Game Sounds like you're on the right track with your day-night cycle and lightmap management! Using Addressables for your lightmaps is a good idea, as it allows for more flexible loading and unloading, which is crucial for mobile performance. About Your Current ARead more

    Optimizing Lightmaps for Your Mobile Game

    Sounds like you’re on the right track with your day-night cycle and lightmap management! Using Addressables for your lightmaps is a good idea, as it allows for more flexible loading and unloading, which is crucial for mobile performance.

    About Your Current Approach

    Your plan to group lightmap data in a ScriptableObject is solid. This way, you can easily manage and modify your lightmaps. Just remember, when you mark it as Addressable, it’ll help with loading/unloading, but you still need to handle the memory part carefully.

    Memory Management

    Regarding your question about the private array _lightmaps: yes, if it’s holding references to your lightmaps and you don’t release them, they’ll stay in memory. To release the lightmap ScriptableObject, you should call Addressables.Release on it when you’re done using it. This will free up the memory in a more efficient way.

    Loading Strategies

    As for loading strategies, both of your ideas have merit! Here are a couple of thoughts:

    • Batch Loading: Loading a limited number of lightmaps at once and releasing them immediately after use could keep memory usage lower and more predictable.
    • Bulk Loading: Loading multiple lightmaps at once and releasing after use might be simpler to implement but could lead to higher memory consumption at once. Just make sure to monitor memory usage.

    Recommendation

    It might be beneficial to start with the batch loading approach as it provides a good balance between preloading assets and memory management. As you get more comfortable, you can experiment with the bulk loading.

    Lastly, always keep an eye on performance and memory usage, especially on mobile devices. Profiling tools can help you figure out what works best for your game. Good luck with your project!

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  3. Asked: May 6, 2025

    How can I implement a linked list in C to manage multiple projectiles in SDL2 without waiting to fire again?

    anonymous user
    Added an answer on May 6, 2025 at 12:14 pm

    Implementing a Linked List for Multiple Bullets in SDL2 If you want to allow multiple bullets to be fired at once in your game, using a linked list is a great way to manage the bullets. Here’s a simple way to set it up. Step 1: Define the Bullet Structure Your bullet could be defined in a way that iRead more

    Implementing a Linked List for Multiple Bullets in SDL2

    If you want to allow multiple bullets to be fired at once in your game, using a linked list is a great way to manage the bullets. Here’s a simple way to set it up.

    Step 1: Define the Bullet Structure

    Your bullet could be defined in a way that includes the necessary properties:

    
    typedef struct Bullet {
        int x, y; // Position of the bullet
        int width, height; // Dimensions
        struct Bullet* next; // Pointer to the next bullet
    } Bullet;
        

    Step 2: Create Functions for Linked List Operations

    You’ll need a few functions to manage your linked list:

    Function to Create a Bullet

    
    Bullet* createBullet(int x, int y) {
        Bullet* newBullet = malloc(sizeof(Bullet));
        if (!newBullet) return NULL; // Check for memory allocation
        newBullet->x = x;
        newBullet->y = y;
        newBullet->width = 50; // Example values
        newBullet->height = 50; // Example values
        newBullet->next = NULL;
        return newBullet;
    }
        

    Function to Add a Bullet to the List

    
    void addBullet(Bullet** head, int x, int y) {
        Bullet* newBullet = createBullet(x, y);
        newBullet->next = *head; // Add to the front of the list
        *head = newBullet;
    }
        

    Step 3: Update Bullets in the Game Loop

    As you process the game loop, you can update and render the bullets:

    
    void updateBullets(Bullet* head) {
        Bullet* current = head;
        while (current != NULL) {
            current->y -= 5; // Move bullet up (example)
            // Here you'd use SDL to render the bullet
            current = current->next;
        }
    }
        

    Step 4: Handle Spacebar Press

    To fire a bullet, check for the spacebar press and add a bullet to the list:

    
    if (spacebarPressed) { // Replace with your actual input check
        addBullet(&bulletList, playerX, playerY); // Use player's position
    }
        

    Step 5: Clean Up

    Lastly, don’t forget to free the memory for each bullet when they’re no longer needed:

    
    void freeBullets(Bullet* head) {
        Bullet* temp;
        while (head != NULL) {
            temp = head;
            head = head->next;
            free(temp);
        }
    }
        

    This should give you a good foundation for managing multiple bullets in your game. Just remember to call your update and render functions in your main game loop, and keep your linked list tidy by freeing up memory when you’re done with your bullets!

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  4. Asked: May 6, 2025

    Why do my tessellation and geometry shaders fail to render, despite correct setups and shader code?

    anonymous user
    Added an answer on May 6, 2025 at 10:14 am

    It sounds like you're running into a tricky issue with shader stages! When you're dealing with both tessellation shaders and geometry shaders, there are a few things to check since they interact in specific ways. First, make sure that your TCS is properly outputting the necessary data that the GS reRead more

    It sounds like you’re running into a tricky issue with shader stages! When you’re dealing with both tessellation shaders and geometry shaders, there are a few things to check since they interact in specific ways.

    First, make sure that your TCS is properly outputting the necessary data that the GS requires. If your GS expects certain attributes but they’re not being passed from the TCS, you’ll run into issues like the output error you’re seeing. Double-check your shader code to confirm that you are declaring the outputs of the TCS correctly.

    Your TCS should have outputs defined like this:

            layout (vertices = 3) out; // or whatever your patch size is
            out vec3 tessCoord; // Example output
        

    And then in your GS, make sure you’re using those outputs:

            in vec3 tessCoord[]; // matching the output from TCS
        

    If you’re getting “TEInstanceID not declared as an output”, it typically means that either you didn’t declare that variable in your TCS output or you are not appropriately passing it to the rest of the shader pipeline. Make sure to follow the naming conventions and that the variable is accessible.

    Also, since you’re trying to use the GS, ensure the inputs for the GS match what your previous shader stage outputs. Mismatched types or missing variables can prevent proper linking.

    As for the rendering issue, when switching between OpenGL versions, keep an eye on any added requirements or deprecated features that might affect your shaders. It’s possible that something may have changed between 4.1 and 4.5 that you’re not accounting for.

    Lastly, if it helps, try debugging step by step by isolating each shader stage and confirm they work individually first before combining them. This may help narrow down where things are going wrong.

    Good luck sorting this out, and don’t hesitate to share your shader code if you want others to help spot any specific issues!

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  5. Asked: May 6, 2025

    Is using JSON for item data instead of RDB a viable solution for performance, given the complexity of item properties?

    anonymous user
    Added an answer on May 6, 2025 at 8:14 am

    It sounds like you’re really in the weeds with this project! Dealing with game data can be a real headache, especially when performance and complexity are on the line. Here are a few thoughts that might help you think through this. 1. Regarding whether JSON can replace an RDB: If the complexity of yRead more

    It sounds like you’re really in the weeds with this project! Dealing with game data can be a real headache, especially when performance and complexity are on the line. Here are a few thoughts that might help you think through this.

    1. Regarding whether JSON can replace an RDB: If the complexity of your item properties is really high and the structure is constantly evolving, then JSON could definitely make sense as a more flexible option. It would let you define item properties without the rigid structure of a relational database. However, keep in mind that you might lose some benefits, like data integrity and easier querying, that an RDB provides. If you’re worried about performance, maybe cache the API results and refresh them periodically instead of hitting it every time.

    2. For alternatives to an RDB, you might want to consider NoSQL databases like MongoDB or even just using simple JSON files. These solutions can handle semi-structured data really well, and you won’t have to deal with the complexity of RDB schema management. However, keep in mind that if you go the file route, you’ll need to implement loading and parsing logic on your end.

    Since you mentioned using the fly-weight pattern—this might actually work well with both JSON and NoSQL, allowing you to save memory by sharing common object instances. Just make sure to weigh the trade-offs between the flexibility of JSON and the structure of an RDB.

    At the end of the day, it depends on your specific needs and what feels right for your project. Trust your instincts and remember to iterate on your approach. Good luck!

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
1 … 22 23 24 25 26 … 5,301

Sidebar

Recent Answers

  1. anonymous user on How do games using Havok manage rollback netcode without corrupting internal state during save/load operations?
  2. anonymous user on How do games using Havok manage rollback netcode without corrupting internal state during save/load operations?
  3. anonymous user on How can I efficiently determine line of sight between points in various 3D grid geometries without surface intersection?
  4. anonymous user on How can I efficiently determine line of sight between points in various 3D grid geometries without surface intersection?
  5. anonymous user on How can I update the server about my hotbar changes in a FabricMC mod?
  • Home
  • Learn Something
  • Ask a Question
  • Answer Unanswered Questions
  • Privacy Policy
  • Terms & Conditions

© askthedev ❤️ All Rights Reserved

Explore

  • Questions
  • Learn Something