Gold Coin Acceleration Issues

In the 2D Top Down RPG Course this lesson is about adding the gold going pickup and getting it to move towards the player.

I am not sure what I’m doing wrong, but it looks like the Move Speed is pretty much irrelevant. The only thing that matters is the acceleration speed. This makes sense since the acceleration is what gets added and if it’s being added every frame it adds up quite quickly. Even at 0.1 and 60FPS, you would be adding 6f after just 1 second compared to a starting speed of something like 5f.

What’s confusing me is that his values do seem to be working for him. No idea why his are actually moving but mine only go quickly when I adjust the acc.

I’m not stuck and this works for me, but I just want to make sure I’m understanding what I’m doing and the difference between the video and my own results makes me think I’ve missed something.

It is indeed totally irrelevant. moveSpeed gets set to 0 on the very first frame unless the coin is already within range of the player.

In the fixedUpdate we’re also multiplying the values for velocity by fixedDeltaTime, which is not necessary for velocity.

I wouldn’t be able to tell if you did something wrong because I can’t see the difference between your code and his.

My code is basically the same as his (aside from using fixedDeltaTime while he uses deltaTime in his code), but his values are so low and he’s getting a high speed result.

But that abso-LUTE-ly makes sense now that you said it that we’re resetting to zero so they’re always starting at zero when the player is in range. Silly. Thank you for pointing that out.

Maybe a better way would be setting it to the moveSpeed when the player is in range, if it’s less than the moveSpeed. My guess is that’s how it’s supposed to work.

Thank you again for the clarification.

Privacy & Terms