Oui je sais dans la réalité c'est impossible, pourtant
je voudrais que mon player soit affecté par la gravité vers le bas par rapport à sa propre orientation et non par rapport au monde.
En fait je voudrais qu'il puisse marcher sur les murs ou le plafond.
J'utilise un script qui me permet de l'orienter par rapport à la surface sur laquelle il est posé. Mais je n'arrive pas le faire déplacer normalement sur cette surface
Voila mes scripts:
Code : Tout sélectionner
Vector3 myNormal;
Vector3 surfaceNormal;
Quaternion targetRot;
public float speedRot = 100f;
private void FixedUpdate()
{
OrienteLePlayerSelonLaNormale();
transform.rotation = Quaternion.Lerp(transform.rotation, targetRot, speedRot * Time.deltaTime);
}
void OrienteLePlayerSelonLaNormale()
{
Ray ray;
RaycastHit hit;
//ne réagit qu'au layer 8
int mask = 1 << 8;
ray = new Ray(transform.position, -myNormal);
if (Physics.Raycast(ray, out hit, Mathf.Infinity, mask))
{
surfaceNormal = hit.normal;
}
else
{
surfaceNormal = transform.up;
}
myNormal = surfaceNormal;
Vector3 myForward = Vector3.Cross(transform.right, myNormal);
targetRot = Quaternion.LookRotation(myForward, myNormal);
}
Merci