unexpected symbol 'float' C#

float lastPositionY = 0f;
float FallDistance = 0f;

functionUpdate ()
{
if(grounded)
{
FallDistance = 0;
lastPositiony = 0;
}
else
{
if (lastPositionY > player.transform.y)
{
FallDistance += lastPositionY - player.transform.position.y;
}
lastPositionY = player.transform.position.y;
}
}

You’re mixing C# and JS within the same file. You have to follow the scripting style of the file’s extension (.cs or .js)

1 Like

I just redid it, here is the new code for fall damage if anyone is interested. The player.SendMessage(“ApplyDamage”, FallDistance*10); line is sending a message to the player to call a function of applying damage.
#pragma strict

var LastPositionY = 0;
var FallDistance = 0;
var player : Transform;

private var controller : CharacterController;

function Start()
{
controller = GameObject.Find(“Player”).GetComponent(CharacterController);
}

function Update()
{
if(LastPositionY > player.transform.position.y)
{
FallDistance += LastPositionY - player.transform.position.y;
}

LastPositionY = player.transform.position.y;

if(FallDistance >= 5 && controller.isGrounded)
{
player.SendMessage(“ApplyDamage”, FallDistance*10);
ApplyNormal();
}

if(FallDistance <= 5 && controller.isGrounded)
{
ApplyNormal();
}
}

function ApplyNormal()
{

FallDistance = 0;
LastPositionY = 0;
}

I would strongly suggest investigating C# instead of UnityScript.