Hi
I’m controlling my player with a Character Controller and Joystick (utilising the joystick script supplied by Unity).
During gameplay, if an enemy hits the player, I disable the joystick whilst the player flashes (I just turn the material on and off a few times) and the player loses a life. Joystick/control is returned to the player at the end of this.
The problem with this is that if the player is moving at the time they hit the enemy, the character keeps on moving in the direction at the time of the hit.
What I want to achieve is that as soon as the player hits the enemy they come to a standstill at that position.
For movement (in the sidescrollerscript), I’m using (in Update function):
if ( moveTouchPad.position.x > 0.7 moveTouchPad.position.x !=0){
movement = Vector3.right * forwardSpeed * moveTouchPad.position.x;
} else if (moveTouchPad.position.x < 0.7 moveTouchPad.position.x !=0) {
movement = Vector3.right * backwardSpeed * moveTouchPad.position.x;
}
.... etc
movement += velocity;
movement += Physics.gravity;
movement *= Time.deltaTime;
Thanks for any advice on this.