Hello there, awesome people!
I am sorry if this question has been asked already or if it is somewhat stupid.
But I am currently working on an old school 2D platformer in Unity.
I’ve set up my own character controller which kinda works.
However, I noticed that in nearly every tutorial I’ve seen, people tend to use transform.position or transform.translate to move their sprites/objects and give them a kinematic rigidbody2D.
Currently, this is exactly what I do as well and it’s been working quite well.
I use raycasts for collision detection and stuff.
Well, the point is…
Let’s say the player stands directly in front of an enemy. The player and the enemy are both using the same controller script. The player is supposed to take damage if he collides with the enemy.
Since the speed is scaled by Time.deltaTime, there might be potential “skips” in the movement.
Let’s say a player has a real sh*tty PC and is running the game with a framerate of 10 fps.
Now during a frame the player moves, say 16 pixels, forward and so does the enemy.
Therefore, they practically “tunnel” each other and never actually collide.
So that’s why I wonder why people keep telling me to use the transform component.
What is the best way for a 2d platformer to handle such an issue? Should I just use rb2D.MovePosition instead? The built in physics just don’t feel “oldschool” enough, plus I would like to have total control over the physics of my game.
Should I avoid relying on the transform component completely?
I’ve been tweaking around and googling this stuff but I just can’t find the ideal way to handle this.
Your feedback would be highly appreciated.
Thanks for your attention, everybody!
Enjoy your day!