I have an SKSpriteNode that looks like a trapezoid, with the code like this:
bezierPath = [UIBezierPath bezierPath];
[bezierPath moveToPoint:CGPointMake(0, 0)];
[bezierPath addLineToPoint:CGPointMake(90, 90)];
[bezierPath addLineToPoint:CGPointMake(374, 90)];
[bezierPath addLineToPoint:CGPointMake(462, 0)];
CGPathRef path2 = bezierPath.CGPath;
self.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:path2];
self.physicsBody.dynamic = NO;
I remember reading somewhere that an SKSpriteNode must be convex, and this shape certainly seems convex. What happens in the program is, when a vehicle runs over this trapezoid shaped bump, what seems to happen is that the vehicle goes below the trapezoid shape. Can anyone help me with this problem?
That's clockwise winding; it needs to be counterclockwise. Reverse the order of your points.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With