public void Walk() { RaycastHit2D hit = dollRaycast.RaycastClosest(transform.position, Vector2.down, 3); if (hit) { Vector2 dir = (targetPos - (Vector2)transform.position); walk_direction = dir.x < 0 ? -1 : 1; WalkCycle(walk_direction); Vector2 walkVector = (walk_direction * hit.normal) * movement_speed; walkVector = new Vector2(walkVector.y, -walkVector.x + .1f * movement_speed); hip.OverloadMuscleRot(6); hip.AddMovement(walkVector); } }
public void Walk() { //RaycastHit2D hit = Physics2D.Raycast(transform.position + Vector3.left * 2, Vector2.down); RaycastHit2D hit = dollRaycast.RaycastClosest(transform.position, Vector2.down); Vector2 dir = (targetPos - (Vector2)transform.position); walk_direction = dir.x < 0 ? -1 : 1; WalkCycle(walk_direction); Vector2 walkVector = (walk_direction * hit.normal) * movement_speed; walkVector = new Vector2(walkVector.y, -walkVector.x + .1f * movement_speed); //hip.AddForce(dd , ForceMode2D.Impulse, true); hip.OverloadMuscleRot(6); hip.AddMovement(walkVector); //hip.AddMovement(Vector2.right * walk_direction * movement_speed); }