Individual particles and physics in Sprite Kit - ios

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.

Related

Is collision detection in Sprite Kit deterministic when not using physics?

I have found out thanks to this article: http://blog.element84.com/comparing-sprite-kit-physics-to-direct-box2d.html and personal experience that Sprite Kit is not deterministic when using physics simulations. However I was wondering if the collision logic actually deterministic when handling the node's position in a deterministic way. i.e. Repeatability works fine but my position handling.
Thanks!
UPDATE: Added more detail
In SpriteKit, physics simulations don't seem to be deterministic since they are evaluated in the game loop and depending on the frame rate of the device they can be executed at different rates. My question, is collision detection (such as the didBeginContact method) for physics bodies independent from the loop and called right after the position of the node has changed. I am trying to use only the collision properties from Sprite Kit to achieve repeatability in 2 instances that might perform at different frame rates.
Just in case this could help someone, I just found out that all collisions happen in the Sprite Kit loop, therefore they are not repeatable nor deterministic for that matter.

Continuous collision in cocos2d-x 3.0 built-in physics (chipmunk)

I have used cocos2d-x-3.0 built-in physics for my game.
My problem is that my physics bodies are passing through physics boundaries, around the physics world. It is observed when physics body size is small and velocity is high.
I used box2d for my past native (cocos2d-iPhone) games, there, I solved this problem by enabling isBullet property of physics bodies but here, chipmunk does not support this (continuous collision).
Is there a way to fix it? or should I leave built-in physics engine and implement box2d by my own?
Now you can try to use PhysicsWorld::setSubsteps
One physics update will be divided into several substeps to increase its accuracy. Or PhysicsWorld::setUpdateRate Set it higher can improve performance, set it lower can improve accuracy of physics world simulation. I hope this helps:)

Making a Laser which stops at objects in spritekit

Is it possible to make a laserbeam in ios spritekit that will change length depending on the angle and if there is any objects in the way? its hard to explain but check the image.
This is possible. 'Line Of Sight' type of techniques are very well explained in Sprite Kit Programming Guide: Simulating Physics chapter.
Listing 8-10 Casting a ray from the center of the scene is a code snippet that is on the right track.
Provided the objects that the laser will hit all have physics bodies then you should be able to use enumerateBodiesAlongRayStart:end:usingBlock: from SKPhysicsWorld class. Think of this method as firing an invisible ray first, so you can get the end point for the laser beam you wish to draw.

Sprite Kit Realistic Bone Animation

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.

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