rakim87
November 30, 2015, 9:20pm
1
func tick(dt: NSTimeInterval) {
velocity = velocity + acceleration * dt
position = position + velocity * dt
position.y = max(0, position.y)
}
The 2nd and 3rd lines get errors saying "Binary operator “*” cannot be applied to operands of type “Vector” and “NSTimeInterval”
Maybe I overlooked something?
[quote=“rakim87”] func tick(dt: NSTimeInterval) {
velocity = velocity + acceleration * dt
position = position + velocity * dt
position.y = max(0, position.y)
}
The 2nd and 3rd lines get errors saying "Binary operator “*” cannot be applied to operands of type “Vector” and “NSTimeInterval”
Maybe I overlooked something?[/quote]
Any answer for that? I have the same problem.
ibex10
January 18, 2016, 5:34pm
3
Both acceleration and velocity are of type Vector , but dt is of type scalar (that is, it is of type NSTimeInterval .)
Therefore, you need to overload the binary operator ‘*’ so that it can operate on a vector and a scalar as arguments.