void Attack(int ahand) { int _attackingHand = ahand; _Muscle _hand = hand[_attackingHand]; Vector2 dir = (targetPos - (Vector2)transform.position); if (AttackState[_attackingHand] == 1) { AttackState[_attackingHand] = 2; attack_direction = 1; fl = (int)Direction.right; sl = (int)Direction.left; if (dir.x < 0) { attack_direction = -1; fl = (int)Direction.left; sl = (int)Direction.right; } } upper_leg[fl].OverloadMuscleRot(25 * attack_direction, AnimStrength); lower_leg[fl].OverloadMuscleRot(25 * attack_direction, AnimStrength); lower_leg[fl].AddForce(new Vector2(-5 * attack_direction, -5)); lower_leg[fl].bone.velocity *= Vector2.zero; upper_leg[sl].OverloadMuscleRot(0, AnimStrength); lower_leg[sl].OverloadMuscleRot(-25 * attack_direction, AnimStrength); lower_leg[sl].bone.velocity *= Vector2.zero; hip.bone.velocity *= Vector2.zero; hip.OverloadMuscleRot(AnimStrength * 5); //// Vector2 hand_dir = _hand.GetRootDirection(targetPos); if (hand_dir.magnitude > range) { hand_dir = hand_dir.normalized * range; } if (reversed_dir[_attackingHand]) { hand_dir.x *= -1f; } _hand.AddForce(hand_dir * Force); time += Time.fixedDeltaTime; if (time > switchTime) { time = 0; reversed_dir[_attackingHand] = !reversed_dir[_attackingHand]; } //Attacks[_attackingHand].Attack(targetPos, AttackForce, AttackForce); }
void Start() { dollRaycast = new _RaycastDoll(transform); foreach (_Muscle muscle in muscles) { musclesByRg.Add(muscle.bone, muscle); } lower_leg[(int)Direction.right] = musclesByRg[_legbr]; lower_leg[(int)Direction.left] = musclesByRg[_legbl]; upper_leg[(int)Direction.right] = musclesByRg[_legur]; upper_leg[(int)Direction.left] = musclesByRg[_legul]; hip = musclesByRg[_hip]; }