[Swift 2] Day 3 - Asteroid Belt


#1

Post any questions, solutions, or code here for Day 3.

Game Lessons


#2

PlayerShip is created as volume based physics body so it had to be affected by the angular force when an asteroid hits for example the wing of the ship, in other words ship has to start rotating. Similarly to “dynamic” property “allowsrotation” property is True by default, so why the ship is not rotating?


#3

If you have dynamic = false and allowrotation = true, your ship will still not rotate, it has to be dynamic to rotate. Also you might want to look at the mass values of things , if your ship has a great mass value compared to the body it was in contact with - it wont be affected much :wink:


#4

If you use a circle as the physics body, you don’t see rotations either.

Make sure to either use a polygon, rectangle, or per pixel using the alpha as I demonstrate.


#5

But if he is using your art for the ship and doing SKSpriteNode, using the image, then the physics body should be the exact same size of the sprite correct ?


#6

It would be pixel accurate if @IamMashed used my code as I typed it.

@IamMashed I would need to see code, can you post it like I demo’ed in the course video on sharing your code?


#7

Code is the same, chief. I do not change anything. I guess first reply by Ravenshore makes sense.


#8

Mass values should be calculated by area, though you can overide the values if you want.

If you resize, I don’t think I’ll change mass, so you’d have to adjust after changing size (or create a new physics body)

Dynamic needs to be set, good find!