Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: bx83 on Sat 17/07/2021 00:41:11

Title: cannot convert int to floats... in an expression using only floats.
Post by: bx83 on Sat 17/07/2021 00:41:11
vc[0] = Maths.Sqrt( Maths.RaiseToPower(Fcx-Ftmx, 2) + Maths.RaiseToPower(Fcy-Ftmy, 2) );

vc[] is an array of floats, all variables inside expression are floats, RaiseToPower is a floats-only function.

Error: Type mismatch: cannot convert 'int' to 'float'

???
Title: Re: cannot convert int to floats... in an expression using only floats.
Post by: Crimson Wizard on Sat 17/07/2021 00:55:56
You already had a similar topic opened few days ago...

Maths.RaiseToPower (https://adventuregamestudio.github.io/ags-manual/Maths.html#mathsraisetopower)

both arguments should be float, but your second argument is integer.
Title: Re: cannot convert int to floats... in an expression using only floats.
Post by: Khris on Mon 19/07/2021 08:21:56
You need to write  2.0  here, a so-called float literal.