Hola soy un estudiante y estoy aprendiendo un poco más sobre scripting en unity y quisiera saber si alguien me podría explicar este script y como lo puedo aplicar al First Person Controller de unity.
Hello I am a student and I’m learning a little more about scripting in unity and I wonder if someone could explain me this script and as I apply to the First Person Controller of unity.
#pragma strict
var waterlevel : float = 4;
var floatHeight : float = 2;
var bounceDamp : float = 0.05;
var buoyancyCentreOffset : Vector3;
private var forceFactor : float;
private var actionPoint : Vector3;
private var uplift : Vector3;
function Update()
{
actionPoint = transform.position + transform.TransformDirection(buoyancyCentreOffset);
forceFactor = 1f - ((actionPoint.y - waterlevel) / floatHeight);
if (forceFactor > 0f)
{
uplift = -Physics.gravity * (forceFactor - rigidbody.velocity.y * bounceDamp);
rigidbody.AddForceAtPosition(uplift, actionPoint);
}
}
He sacado este código de un vídeo tutorial en youtube de PSD “creating games”.
Quiero aplicarlo para que el FPC pueda flotar cuando pulse espacio y no salte si no que flote, gracias por la atención prestada.
I taken this code from a tutorial video on youtube of PSD “creating games”.
I want to apply for the FPC to float when I press space and do not jump but it afloat, thanks for your attention and excuse me if my english isn’t good
The biggest problem is that the First Person Controller Unity uses a Character Controller physics and the buoyancy script uses RigidBody, I don’t know how to do a First Person Controller that use RigidBody.