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
  • Ubuntu
  • Python
  • JavaScript
  • Linux
  • Git
  • Windows
  • HTML
  • SQL
  • AWS
  • Docker
  • Kubernetes

anonymous user

80 Visits
0 Followers
871 Questions
Home/ anonymous user/Answers
  • About
  • Questions
  • Polls
  • Answers
  • Best Answers
  • Groups
  • Joined Groups
  • Managed Groups
  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

    The issue you're facing with laggy physics during time scale interpolation is indeed linked to how Time.fixedDeltaTime is managed in Unity. Normally, fixedDeltaTime must consistently scale proportionally with timeScale to guarantee physics calculations occur at stable and expected intervals. Using TRead more

    The issue you’re facing with laggy physics during time scale interpolation is indeed linked to how Time.fixedDeltaTime is managed in Unity. Normally, fixedDeltaTime must consistently scale proportionally with timeScale to guarantee physics calculations occur at stable and expected intervals. Using Time.unscaledDeltaTime for adjusting fixedDeltaTime isn’t ideal because it’s frame-rate dependent and can introduce variability or inconsistency, leading to physics lag or stutter.

    A better approach involves explicitly setting Time.fixedDeltaTime directly proportional to the scaled value of your desired default physics step. For instance, Unity’s default fixedDeltaTime is typically set to 0.02 (50 physics updates per second at normal speed). Therefore, modifying your fixedDeltaTime adjustment line to something like Time.fixedDeltaTime = defaultFixedDeltaTime * Time.timeScale; helps maintain consistency across scaled time intervals. Additionally, caching the original fixed delta time at initialization and restoring it when time returns to normal is recommended. This ensures physics interactions remain smooth and predictable both in 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

    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
  3. 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

    Your approach of using a ScriptableObject marked as Addressable to encapsulate grouped lightmap data (textures and baked probes) is sound and aligns well with Unity's recommended practices for managing dynamic assets efficiently. ScriptableObjects provide a clean, organized way of referencing relateRead more

    Your approach of using a ScriptableObject marked as Addressable to encapsulate grouped lightmap data (textures and baked probes) is sound and aligns well with Unity’s recommended practices for managing dynamic assets efficiently. ScriptableObjects provide a clean, organized way of referencing related assets, and marking them as Addressable absolutely makes sense because it gives you granular control over asynchronous loading and unloading. Regarding memory management, storing your lightmap assets in a private array like _lightmaps means these references will indeed remain in memory until explicitly released. To manage memory effectively, you’ll need to call Addressables.Release() or Addressables.ReleaseInstance() on the loaded asset references once they’re no longer required. Be cautious about keeping lingering references to loaded assets in your arrays or variables, as this can prevent proper unloading from occurring.

    When it comes to your loading strategy, batching seems preferable. Given you’re targeting mobile platforms, it’s crucial to limit memory consumption consistently. Loading a small, predictable number of lightmaps at intervals, then releasing them immediately after they’re no longer needed, typically results in better memory efficiency than loading large groups at once. For example, as time progresses in your game’s day-night cycle, load only a small set of relevant lightmaps ahead of their current necessity, and unload those no longer relevant immediately afterward. Keep your batch size manageable to minimize loading overhead and avoid hitching. This incremental loading strategy ensures you maintain performance stability on mobile hardware while avoiding large memory spikes.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  4. 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
  5. 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

    To manage multiple bullets effectively, implementing a simple linked list is your best bet. First, define a bullet node structure which contains the bullet position, dimensions, velocity, and a pointer to the next node: typedef struct Bullet { SDL_Rect rect; int velocity; struct Bullet* next; } BullRead more

    To manage multiple bullets effectively, implementing a simple linked list is your best bet. First, define a bullet node structure which contains the bullet position, dimensions, velocity, and a pointer to the next node: typedef struct Bullet { SDL_Rect rect; int velocity; struct Bullet* next; } Bullet;. When the player presses the spacebar, dynamically allocate a new bullet: Bullet *new_bullet = malloc(sizeof(Bullet)); then initialize its properties, such as position and velocity. Next, insert this node into the linked list by pointing its next pointer to the current head of your bullet list, and update the head to your new bullet: new_bullet->next = bullet_list; bullet_list = new_bullet;. This approach allows for dynamically managing multiple bullets independently without relying on the fixed-size structure you’re currently using.

    Inside your main game loop, iterate through the linked list to update bullet positions based on their velocities, handle boundary checks, and render each bullet. This would look something like: for (Bullet *curr = bullet_list, *prev = NULL; curr != NULL;) { curr->rect.y -= curr->velocity; SDL_RenderCopy(renderer, bulletTexture, NULL, &curr->rect); if (curr->rect.y < 0) { Bullet *tmp = curr; if (prev == NULL) bullet_list = curr->next; else prev->next = curr->next; curr = curr->next; free(tmp); } else { prev = curr; curr = curr->next; } }. This ensures bullets are smoothly created, updated each frame and removed once they leave the screen, providing a scalable and clean solution for your multiple-projectile scenario.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  6. 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
  7. 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

    The linking error you're encountering ("TEInstanceID not declared as an output from the previous stage") points to a mismatch in interface variables between the Tessellation Evaluation Shader (TES) and the Geometry Shader (GS). Unlike vertex-to-fragment or vertex-to-tessellation stages, each shaderRead more

    The linking error you’re encountering (“TEInstanceID not declared as an output from the previous stage”) points to a mismatch in interface variables between the Tessellation Evaluation Shader (TES) and the Geometry Shader (GS). Unlike vertex-to-fragment or vertex-to-tessellation stages, each shader interface variable must explicitly match by name, type, and qualifier. Specifically, when a GS is active following tessellation shaders, the output variables of your TES must exactly match (by type, qualifier, and name) the input variables declared in the GS. It’s common to overlook explicitly declaring built-in variables correctly at each stage; for example, “gl_InstanceID” is built-in and accessible, but “TEInstanceID” is not recognized unless explicitly defined in TES’s outputs.

    To ensure your pipeline works correctly with TCS, TES, and GS together, explicitly declare any custom interface variables used by the GS as outputs in the TES. For instance, define something like out int TEInstanceID; in your TES and correspondingly in int TEInstanceID[]; (as an array) in your GS input interface. Alternatively, rely on built-in variables when possible, such as gl_InvocationID or gl_PrimitiveID, which don’t need explicit passing. Additionally, double-check your tessellation shaders—if you use pass-through implementations, ensure that they explicitly forward vertex outputs to interface variables also defined in subsequent shaders. Confirm that the GS input layout qualifier matches the TES output primitive type: for tessellated meshes, typically you’d use layout(triangles) or similar in GS input declaration.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  8. 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
  9. 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

    Your idea to separate static, complex item data makes sense; JSON or a document-oriented NoSQL solution like MongoDB can significantly simplify development complexity. Complex nested structures can become a headache in relational databases, especially when using JPA annotations excessively to handleRead more

    Your idea to separate static, complex item data makes sense; JSON or a document-oriented NoSQL solution like MongoDB can significantly simplify development complexity. Complex nested structures can become a headache in relational databases, especially when using JPA annotations excessively to handle embedded relationships and collections. Rather than fighting against relational paradigms, leveraging JSON files or document-based databases would allow you to inherently represent complex hierarchical data structures without the continuous mapping hassle and performance concerns associated with repeated API hits.

    If your item data is relatively stable and changes infrequently, a static JSON approach could indeed be sufficient. Alternatively, considering solutions like MongoDB or Couchbase can offer greater flexibility and scalability while still being easy to integrate with your current Java setup. Meanwhile, reserving your relational database for rapidly changing user-specific information—such as enchantments and player customizations—is likely the ideal way to achieve both performance and clarity. Splitting responsibilities clearly between database types also aligns neatly with your existing fly-weight implementation approach, maintaining readability and optimizing performance.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  10. 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,381

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

  • Ubuntu
  • Python
  • JavaScript
  • Linux
  • Git
  • Windows
  • HTML
  • SQL
  • AWS
  • Docker
  • Kubernetes