|Topic was automatically imported from the old Question2Answer platform.
Player and NPC walk like this:
# calculate velocity
move_and_collide(velocity * delta)
Now, let’s say an NPC is walking to the right and the player runs into him from the top. I want the player to stop immidiately and the NPC to move along. But in reality, the player can go downwards at a very low speed, pushing the NPC. The NPC can do the same to the player as well. Maybe the same reason I can “slide” on the floor slightly if I hold down and right at the same time?
What’s happening here? And what can do to fix this? Any help would be appreciated.
the docs state …
A kinematic character controller is assumed to always begin in a non-colliding state, and will always move to a non-colliding state. If it starts in a colliding state, it will try to free itself like rigid bodies do, but this is the exception, not the rule. This makes their control and motion a lot more predictable and easier to program. However, as a downside, they can’t directly interact with other physics objects, unless done by hand in code.
the statement in bold is the reason for your sliding movement.
I would try to reset the kinematic body to the position before the collision has happend. This will stop the object from sliding along.
Can I ask how you would reset the kinematic body’s position? I put this in both character’s script:
var collision = move_and_collide(velocity)
It did stop the sliding but caused many other problems: now I’m pushed back when I try to push him head-on, and characters vibrate when trying to push things. Am I doing it wrong?
those are many more questions.
I dont understand your setup … some things should be pushed others not. So you have to branch your collision reaction by the sort of the collider.
Sounds too complicated for me… I’m going to just stop npcs when they are close to the player for now. Or maybe let npcs pass through the player. Anyway, thank you for your help
hey … just hang in there. It aint easy yet but will be soon.
Maybe check some example projects for there method of dealing with those things.