- Home /
How can i make float u = 1 – t; ? I'm getting errors
Vector3 Test(float t)
{
float u = 1 – t;
}
I'm getting error on the '-'
Unexpected character '–'
And Only assignment, call, increment, decrement, and new object expressions can be used as a statement
And error on the t:
; expected
private float Test2(float t)
{
return 1 - t;
}
private Vector3 Test3(float t)
{
return new Vector3(0, 1 - t, 0);
}
usage : float myFloat = Test2(1);
Vector3 myVector3 = Test3(1);
I think you're using – [En dash] ins$$anonymous$$d -[$$anonymous$$inus]. and also what does it gonna do?:D.
Yep! Dunno what that is but it's not a $$anonymous$$us sign.. it's evil :D
Answer by Bunny83 · Sep 09, 2017 at 08:03 AM
Like @PersianKiller pointed out correctly your code does not contain a "normal minus" but an "en dash". Only the normal minus sign is recognised as "minus operator". The "en dash" is recognised as a normal character. So this should result in the same error and basically does the same:
float u = 1 foobar t;
Of course this doesn't make much sense. This is not valid code as you have a "number" followed by two identifiers "foobar" and "t".
Next thing is your method has Vector3 as return type. If a method has a return type you have to return a value of that type. Though it's not clear what this method should do. That's basically the next thing: Name your methods propertly so it becomes clear what the method does. Otherwise you could call all your methods "A0001" and "A4242". The compiler doesn't mind how you name it. The name should be useful for the programmer to understand the program.
There might be another error depending on where you put that code snippet.
Your answer

Follow this Question
Related Questions
How can i lock the mouse cursor in the middle of the screen ? 1 Answer
Why InputField don't have the property text ? 2 Answers
How can i change the walls height and keep the size for example 100x100 but height 0.1 ? 1 Answer
How can i using a break point if a gameobject have a collider after added to it ? 1 Answer
How can i get all childs from List ? 3 Answers