New answers tagged

2 votes

Emulating 3d trajectory in top-down 2d game?

I created this version which uses a target position and t (time 0-1). I would loop this function in an update function if (t < 1) t would increase by ...
Joel Leonard-Best's user avatar
1 vote

Changing the scale of a character and speed to match the perspective of a 2D background while traveling along the Y axis

You have the correct idea. It might be easier to manage if you define the scale at two different points and interpolate/extrapolate it. For example, if you know that \$Y_1\$ the scale should be \$S_1\$...
Theraot's user avatar
  • 24.5k
0 votes

How to Prevent Enemy Overlap

If you are ok with more work on sprites you could simply use different sprites for the enemies. You could have enemies composted of randomized different parts. This is probably overkill just for this ...
Piro's user avatar
  • 157
0 votes
Accepted

How can I solve this error and this warning when destroying instantiated prefabs?

I solved this problem more than a month ago but forgot to post an answer. So, here's the answer: Basically, instead of constantly instantiating enemies, I put a number of them above both triggers and ...
Ali's user avatar
  • 45
2 votes

Is there a logical reason for SFML's Vector2 being templated?

Why would you ever want to use any other type than float for positional math? The other answer covers this pretty well but some aspects of your post has not been tackled. Is there a logical reason ...
Vaillancourt's user avatar
  • 16.3k
1 vote

Can I rotate the velocity of a rigid body?

I got it working using DMGregory's suggestion. This line is the ticket, just adjust the "20". ...
dotexe's user avatar
  • 11
2 votes

KinematicBody2D stutters/moves back and forth

Are you not overshooting your target? You have this code: ...
Theraot's user avatar
  • 24.5k
0 votes
Accepted

How to rotate NavMeshAgent toward its movement direction?

You can avoid the trig and angles by using the LookRotation helper method in a slightly different way: ...
DMGregory's user avatar
  • 130k
0 votes

How to rotate NavMeshAgent toward its movement direction?

I've solved it with help of ChatGpt. Here's the code ...
A-Eye's user avatar
  • 3
0 votes

How to make 2D lighting in JavaScript

Sorry for reviving the question, I know its already answered, but I came up with my own solution that does require an offscreen canvas, but it is pretty fast. (WASD to move camera, scroll wheel for ...
Pete21's user avatar
  • 1
3 votes
Accepted

Is there a logical reason for SFML's Vector2 being templated?

Unity, for example, has both Vector2 and Vector2Int types (and so on for other dimensionalities), since C# didn't/doesn't have ...
DMGregory's user avatar
  • 130k

Top 50 recent answers are included