New answers tagged

1

If you want deceleration to be linear, you can subtract a fixed amount from the length of the vector, or set the vector to zero if it below the step size. So you might have something like: float len = velocity.length(); if (len < difference) { velocity.x = 0; velocity.y = 0; } else { velocity -= velocity / len * difference; // direction stays ...


3

If you don't need the deceleration to be the same fixed amount each frame, you can instead apply a "drag multiplier". This is used in many games as a crude approximation of air resistance, where the faster you go, the more air you have to push through per unit of time, increasing the friction at high speeds. public float velocityMultiplier = 0.95f; ...


0

This seems too silly to be correct, but I achieved the desired result with the following: In the method that handles the camera moving... stage.addListener(new DragListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } @Override public ...


2

Checking the Wikipedia article on Network Time Protocol, we find this Windows documentation as one example: Under the right operating conditions, systems running Windows 10 or Windows Server 2016 and newer releases can deliver 1 second, 50ms (milliseconds), or 1ms accuracy. To achieve the tighter 50 ms bound, the documentation says: The target computer ...


0

Solved : I added this line in update method of player controller cam.position.set(player.transform.getTranslation(new Vector3())); Now the camera move with the player, but I can't now make it rotate with the player.


0

It also depends on the engine you're using, but for example: In Unreal Engine 4, you use something called "Level Streaming" where you open a level that you want to remain persistent (meaning, a level that is always loaded) and add sub-levels to it that load when certain events are triggered. These sub-levels work in a similar way to layers in say, ...


0

There are many strategies to do this, I'll just list the most common the ways people have done them in the past and you can then use this as a jumping off point for more research. Scene files Define a scene (or level) file which specifies where and what is inside the level, you can then use this list to load data as it's needed and unload when you switch to ...


0

Given that the crash is inconsistent, it's probably a threading issue. The link you shared says MacOS users should start their application passing "-XstartOnFirstThread" as a VM option. so I'm guess that you're not properly setting the VM option. Setup a run configuration in build.gradle. Example run config for Gradle: Add to build.gradle run { ...


2

Looks like you need to compare angles and work out their difference. Here's one way to do it: // Returns the difference between two angles, from -180 to +180 degrees. float deltaAngle(float aDegrees, float bDegrees) { float difference = aDegrees - bDegrees + 180.0f; return (float)(difference - Math.floor(difference/360.0f) * 360.0f - 180.0f); } // ...


2

You can make your grid 8x8 and expand all impassible tiles into a 4x4 patch of impassible tiles. Or in other words a tile is impassible if any of the tiles in a 4x4 region around it is impassible. Then you can path find based on a 1x1 entity on that modified grid and when you make an entity follow that path you expand it's location opposite as you expanded ...


1

I found the solution in a badlogic forum. This: modelBuilder.part("minecraft:loading_model", mesh, 4, new Material(TextureAttribute.createDiffuse(atlas), blendingAttribute, FloatAttribute.createAlphaTest(0.95f))); Or this: modelInstance.materials.get(0).set(FloatAttribute.createAlphaTest(0.95f));


1

Please note that we generally expect users to show some effort when asking questions. Also, we expect them to show us only the relevant code necessary for the question. We also expect them to be precise with what they need. Although your question was really badly formatted at first, the downvotes you got probably come from your lack of research and code ...


0

I used Jprofiler and found out i had many waiting/blocked threads. Using this tip from another user i was able to find out the problematic calls in my code: "Go to the call tree view, record CPU data and set the thread status selector to "Blocking", than you see in which call stacks the blocking occurs.Detailed analysis of blocking situations ...


9

Text files are a perfectly fine way to create savegames. It's easy to implement and it allows you as the developer to edit savegame files in a text editor in order to test things more quickly. But for easier parsing and better compatibility between versions, you might want to use a standard markup format like XML, JSON or YAML which you serialize and ...


0

"This looks like a job for a viewport. It looks like libgdx's version has a "right gutter width" property that would be useful here" - DMGregory found it!


Top 50 recent answers are included