Best way to implement a "floating bubble" object - swift

As the title says, I'm trying to find a way to implement a kind of floating bubble (a SKSpriteNode object) inside my game.
I'm using SpriteKitbut I really don't know which is the best way to approach this problem. In particular:
Should I "play" with values inside Xcode Physic Body in order to find good stats which reflects the physic of a soap bubble?
Or I should change the gravity to 0.0 and handle the animations through code? If so, what if I need to implement other objects who need to be affected by the standard -9,8 gravity value?

If i understood what you are thinking....a good idea would be using a Particle Emitter, there you can use a texture and play with lots of options. There you can have lots of bubble, emit them.
If your idea is just animate one or two bubbles....then you may do this with spritekit code (gravity to 0.0), using SKAction to move the bubbles, fade in/out or just play with .alpha.
You can also use gravity to move it...but you will have less control about what bubble is doing...
If you need more help just comment this. Hope i helped you!

Related

Is it possible to animate anything with natural way in Unity or smt else?

I m wondering that if is it possible to animate anything along the rules of physics.
I mean, i have a cube, and two legs attached to that cube. I want to just animate that legs one after each other, but unity or other software will force its animation system to behave to my animated legs to make my cube walk. I wont change positions for my body(cube) but legs will do that.
demonstration:
https://streamable.com/dda610
Yes, this animation type is called procedural animation. You base your animations dynamically based on physics.
https://en.wikipedia.org/wiki/Procedural_animation
good video:
https://www.youtube.com/watch?v=LNidsMesxSE
tutorial:
https://www.youtube.com/watch?v=9Wh6fzSl_u8
Physically based animation is a complex task. You can use the timeline to animate legs but they won't work too well physically. You probably want to use code to keep the body a fixed height above the surface and use the timeline editor to animate the legs. Or perhaps keep the body at the same height and use 'inverse kinematics' to move the legs in a more realistic fashion. Neither of these options will be very quick for you to start using really effectively if you have very little experience with unity or with code but knowing what to look up is half the battle of learning.

How to create directional drag in Unity?

I'm developing a game in which you race in ships that are hovering above the ground. The problem is that they are really difficult to control because the have no friction other than the drag i set in Rigidbody component. Because of that steering is very unresponsive. Setting drag to really high values helps but it works in all directions and thats not what I want. The solution would be making the drag work only sideways so steering is easier, but going forward and backward is normal. Do you know how can I achieve this?
What's your code? Are you adding force by using rigidbody.AddForce? You know that it accepts a second parameter ForceMode.
For example:
rigidbody.addForce(Vector3.up, ForceMode.VelocityChange)
This wil add an instant force, ignoring it's mass. To see other ForceModes, look here :)

What is the best way to handle collision detection between bodies efficiently?

I am new to Cocos2d, Box2d and game development all together, but I have read a good bit of tutorials to at least have a good start on a game set up and working...
Im now at the point where I need to start adding more bodies to a layer and need to check and see if and when my main avatar will collide with any of them..
Common sense seems to tell me that the more bodies I add and the more cases I add checking to see if fixture1 is colliding with fixture2 for instance will bog down the processor at some point..
Are there any best practices and/or efficient algorithms to make these checks more efficient over time as the number of bodies grow?
Any links or direction would be appreciated! thank you!
You can use QuadTree to divide the scene and get a list of bodies that needs to be checked.
(There are a lot of articles shows how QuadTree works, just google it:D )
And if that's a little complex for you. Then you can try to divide your scene into many grid, and make a loop to put bodies in their grid based on their 2d position. Then just check bodies in each grid. It's a lot faster than normal loop.
http://i.stack.imgur.com/W5cBT.png
As of iOS 7 you can use Sprite Kit to handle collisions:
https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Physics/Physics.html#//apple_ref/doc/uid/TP40013043-CH6-SW14

How to Implement waving(Like pendulam) ropes effect in COCOS2D?

I am trying to implement wave effect when any thing hits the hanging object, how can I achieve the both,:
1.Hang an object in air(as it will be a dynamic body which will wave)
2.implement waving effect on that body
Thank You
The answer isn't in cocos2d but in your physics engine, if you are using box2d check the distance joint. not sure on chipmunk.
in testbed example see the chain example.
u can create no of small boxes and joint them looks like rope.
but be careful while specify the anchorpoint.

Is it possible to divide up boundingBox?

In cocos2d, i've got two objects that I want to detect collision with.
Im using CGrectintersectsrect, which has been working fine thus far.
But I want to divide up the bounding box of one of my objects into 4 quarters, so that if my object collides in any one of these quarters, appropriate physics can then be applied.
At the moment, there is only 1 large boundingBox which is insufficient. Ideally I would want 4+...
Is this possible, and if so how could i achieve this?
If not, is there any other avenue that could work?
Thanks everyone, once again :)
The boundingbox method returns a CGRect. You have to divide your rect manualy, there is no pre-made method for that.
Otherwise if there is a lot of objects, the best way to detect the collisions is to use Box2d. You can follow this tuto to see
How To Use Box2D For Just Collision Detection with Cocos2D iPhone tutorial.