Sprite Kit Realistic Bone Animation - ios

I'm developing a game with Sprite Kit. I'm new to the framework and I'm new to the iOS game developement. What happens is, I have physics enabled in my project, so, let's say, I have a sprite and something hits it and it falls. That's ok, that's what I wanted, of course, but, I wanted to make a reallistic falling animation. I created several texture atlas and that's how I tried to create a realistic animation, but it's not that great. Isn't there any way to make it more realistic? Like moving it like a real skeleton, the head, arms and legs move independently from the torso, do I have to create several sprites and like join them? I really have no idea, please help me and thank you very much.

do I have to create several sprites and like join them?
More specifically, you'd create several physics bodies and join them together. And yes, each one would of course have a sprite associated with it. There are several ways to join physics bodies -- hinges, springs, rigid joints, etc. You can read more about it in Connecting Physics Bodies in the Sprite Kit Programming Guide.

Related

How to create a soft body in SceneKit

So.
After many years of iOS development I said it's time to try to do a little game for myself. Now I chose to do it using Apple's SceneKit since it looks like it provides everything I need.
My problem is that I've stumbled upon a huge problem (for me) and searching on Google doesn't yeld any results.
Any idea how do I go about having an object (a sphere for that matter) that deforms itself, say, because of a gravitational force. So basically it should squash on impact with the ground.
Or, how do I go about deforming it when it collides with other spheres, like a soft beach ball would?
Any starting point along those lines would be helpful.
I can post my code here, but I'm afraid it has nothing to do with my problem since I really don't know where to start.
Thanks!
Update
After doing a bit more reading I think that what I want could be doable with Vertex Shaders. Is that a right path to follow?
For complicated animations, you'll generally be better off using a 3D modeling tool like Blender, Maya, or Cheetah3D to build the body and construct the animation. Those tools let you think at a higher level of abstraction. Then you can export that model to Collada (DAE) format and then import it into SceneKit.
https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Basic_Animation/Bounce has a tutorial on building a deforming, bouncing ball using Blender.
SceneKit only does physics using rigid bodies. If you want something to deform, you would have to do it yourself.
It is probably because SceneKit has no way of knowing how an object should be deformed. Should it just compress, should it compress in one direction and expand in all others to preserve it's volume, should only part of the model compress and the rest stay rigid (like the tires on a car).
What you could try is wait for a collision to occur and do the following
calculate and store the velocity after the bounce
disable collision checking on the object
run an animation for the "squash"
enable collision checking on the object
apply the calculated velocity
It will be entirely up to you how real or cartoony you want to make the bounce look.

Individual particles and physics in Sprite Kit

I am a long time user of Stackoverflow but first post.
My question is seemingly simple, is there a way to make particles from an emitter interact with the physics sprites in the scene? (For example, if I am using a particle for rain, and I want it to bounce or bumpy off a sprite of a man with an umbrella. There must be a way, but I don't see a lot of documentation on adding physics to individual particles. Any ideas?
Thanks!
No. There is no way to make SpriteKit's built in particles interact with physics bodies. Every particle property you can control is a property of SKEmitterNode, and it has no properties for setting physics behavior for particles.
The fact is that particles are designed to be very light-weight so that you can have thousands of them on any hardware supported by SpriteKit. Physics simulation is not light-weight.
There is LiquidFun, which is a Box2D extension that simulate the physics of a particle system. This engine is the basis for Apple Spritekit physics engine and you can use it in your game but you have to tweek it a little bit to make it run. There are a lot of tutorials of how to use it in an ios project. I am confident that Apple will have more features added to Spritekit in the future that make the particle system respond to physics.
You could use a SKField to simulate gravity and then another field on your umbrella to repulse it.

Physics Material slow down the game

I have developed game something like coin dozer. And for the smooth movement of coin i have add one Physics Material to each coin but my game is very slow after doing that . Is there any alternative of that or how can i make coin movement smooth without use of Physics material . So can anybody help me to come out from this situation.
So the problem is physics calculation.
DO NOT use the mesh of the graphic as the collider to calculate coin's moving, especially when there are lots of triangles and verts on the mesh. You should choose a simpler collider, maybe something like prism would behavior similar as a coin and reduce a lot of calculation. You can use another simple prism mesh exported from 3d software and make a new game object with that mesh. Stripe off everything related to physics(rigid body, collider and physics material) from the origin coin. Then organize the visible coin without physics and the new added object(which handle all physics) to the same parent. Less triangles in a mesh collider means less calculation. Control the collider mesh triangles as few as possible. I suggest to use a box collider as a start point to check if the performance improves.
Another thing might help is changing the Solver Iteration Count in the Physics Setting. You can try to change it to a lower value (maybe 3 or 4 is enough for a coin game) from the default.
Limit the frame rate to a lower value alse can help, but it is the last way you should go.
You can add physics to the coins with delay. I mean add physics when coin is near to fall. Also you need to destroy every coin body when you are removing the coin out of the scene. If you are removing only sprite the there will be too many bodies on the scene.

Xna collision detection 2d

Hi i am trying to write simple game where there is one player and some simple world like trees or some buildings, player can walk having muchine gun and shoot to world object like trees and finally destroy it, game is top-down so i don't need any gravity. Player can hit a lot of bullets and some monster in world can shoot to. SO there can be a lof of bullets in one time on the screen so i need some good tool to make colision detection. Also important is that player can't now walk on other object, like there is a monster and player and they can't exist in the same place (one shouldn't go on another). Can you recoment me some collision detection engine, mayby should I use Farser or better I should write it my self?
simillar to this http://www.youtube.com/watch?v=u8rWomjyTWI
I have one more question, i am still reading about xna since few days, and i know now that if it goes about colision detection we have pixel or square and circle, now: is there any toll or engine which can pare a texture
mappe it into a polygon and check colision?
Farseer is for physics. Use it if you need complex collision reaction. If you simply need if colission then kill player, you don't need such an engine or library.
Did you read the collision example in the App Hub right?
Link: http://create.msdn.com/en-US/education/catalog/tutorial/collision_2d_perpixel_transformed
Thats probably just enough for your purposes.

Collision detect with iterative sampling - should I use an engine (box2d) or roll my own?

thanks for taking the time to read my question.
I'm writing a 2d top-down shooter game. It is currently using Box2d as a physics engine. The thing is, it isn't really using Box2d to it's fullest potential, just for collision detection and the underlying velocity/rotation update loop. Any plans to add real physics would simply be eye-candy, not a game changer.
Now I chose Box2d because I went through 2 other physics engines, and they just couldn't handle the types of collisions I'm detecting. I'm creating several 'bullets' with very high velocities, and I do not want them to be instant hits on their targets. JigLib and Flixel both had the same problem - bullets were not overlapping enemies at the time of the frame update, and thus were not detected as collisions (i.e. the bullets passed through enemies because they moved to fast).
I moved to Box2d because of it's iterative collision sampling, as well as the SetAsBullet method on bodies. And it works great! But now Box2d is giving me troubles too - generating several bullets per second, or at the same time, is severely lowering my fps.
So I removed Box2d to confirm that it was not a rendering limitation... added my own velocity/rotation system, and I can fire hundreds of bullets per second. Great! But its lacking any sort of collision detection.
So the questions:
1) Should I write my own iterative collision engine?
2) Should I give Box2d a try again, perhaps with some tweaks to make adding new bodies faster?
3) Is there some other alternative, maybe a lightweight physics engine that specializes in this?
4) Do you know of any other techniques or design patterns that could be of use?
Thanks so much for your help!
Edit: I should note, there are not just bullets, but larger, slower projectiles as well. I considered ray casting a line segment to the projectile's previous position, and catching intersections, but that won't work for the larger objects :(
It depends on how complex your situation can become, If you are good at math and physics you can rollout a fast engine that can handle simple collisions more faster than you can learn using box2d, but why should anyone invent the bycicle if there are plenty of them already invented so choose one you like a try using it, i recommend using box2d

Resources