Saving Object Position in Float NOT Object

Hey,

So I’m new to Unity, as you can probably guess by the question I’m also new to Javascript. I’m finding this whole non static variable declaration lark to be more of a curse than a blessing. I’m trying to grab a sprite’s position via x and y coordinates (2D) and use them in a calculation for velocity. However Unity tells me I cannot perform said operation on two “variables” of type object. Which is fair enough. I can’t seem to figure out how to typecast these objects into float type variables, in Java it would have been simple enough but here, in javascript, I’m completely and utterly baffled.

Here’s what I’m using to store the position values:

characterPositionX = character.position.x;
characterPositionY = character.position.y;

The variables declared like so:

var characterPositionX;
var characterPositionY;

I’ve tried using “: float” however I’m pretty sure that’s purely to do with MonoBehaviour and not type casting(?). I’m honestly lost here, if anyone can offer up some help it’d be greatly appreciated.

Cheers,
Lewis

with java background, why don’t you use csharp?