Help with classes and object constructors

Hello, i’m trying to create an object with the attributes “type”, “multiplier” & “duration”. my class is below.

class buff {
	var type : String;
	var multiplier : int;
	var duration : float;
	function buff(buffType : String, buffMultiplier : int, buffDuration : float){
		type = buffType;
		multiplier = buffMultiplier;
		duration = buffDuration;
	}
} 

I want to be able to create a new buff with the aforementioned parameters but i can’t seem to correctly call the constructor.

buff curBuff = new buff(buffType, buffMultiplier, buffDuration);

Common error messages are:
“duration/multiplier/type are not members of Object”
“cannot find visible constructor with the parameters (String, int, float)”
“buff is not set to instance”
& “insert semicolon at the end” onto the constructor line (which already has a semi colon)

i’ve spent hours scouring the internet for help with class constructors to no avail. i’m disappointed unity does not support standard javascript object construction syntax.

Firstly, in Unity there is no JavaScript, the language is UnityScript. And it has some differences.

Secondly, soon Unity will stop using UnityScript at all.
So, try to find another way to solve your problem with UnityScript, or just go coding with C#.

See this post with information about what I’ve said