probleme lancement d'un boomerang
salut j'ai un problème avec deux code de lancement du boomerang
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| public Animator animator;
public Rigidbody axeRB;
float thworPower = 10000;
private bool IsRetrning = false;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
animator.SetTrigger("Lance");
}
}
public void AxThrow()
{
axeRB.isKinematic = false;
axeRB.transform.parent = null;
axeRB.AddForce(Camera.main.transform.TransformDirection(Vector3.forward) * thworPower);
axeRB.AddTorque(axeRB.transform.TransformDirection(Vector3.right) * 100, ForceMode.Impulse);
}
public void ReturnAxe()
{
IsRetrning = true;
axeRB.velocity = Vector3.zero;
axeRB.isKinematic = true;
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public bool activated;
public float rotationSpeed;
public ScriptPerso scriptPerso ;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (activated)
{
transform.localEulerAngles += Vector3.forward * rotationSpeed * Time.deltaTime;
}
}
private void OnCollisionEnter(Collision collision)
{
activated = false;
GetComponent<Rigidbody>().isKinematic = true;
scriptPerso.ReturnAxe();
} |
quand j’appuie sur "A" mon boomerang se lance mais il ne met pas en rotation et ne revient pas a mon personnage il reste tomber par Terre
si je coche "activated" dans l'inspecteur il se met en rotation