enter image description here
I used Hinge Joint but if there's a slight difference in weight between the left and right and left.
I don't want to let it collapse by a certain margin.
I tyied Hinge Joint, it can make seesaw but I want to create a somewhat generous seesaw.
Related
I'm making a game where I move a red cube across a plane with arrow keys (I am setting the velocity in order to get a constant speed) Here is a preview:
game
Currently, I am just using a plane with a grid material/texture. However, I wanted to change one of the tiles in this grid to a different color and detect when my cube passes over it.
My idea was to simply replace the plane with a bunch of quads. However, when I do that and try to navigate my cube across the quads, it seems to collide with the side of the quad and flip up, despite the fact that they are all at the same height and positioned right next to each other.
Is there a way to make the quads flush so when I push my cube over it, it won't collide with the side of the quads? Is there a better way to create this behavior?
You can disable colliders at this quads and add invisible big plane with collider
For some odd reason when I apply gravity to the particle system, all of the particles fly left downward. They are supposed to fly up and then down when you add gravity but for some reason why I do it it fly s to the left. does anybody know what my problem might be?
Your coordinate system is probably broken.
Gravity is applied in downwards direction globally, so if your global down points towards the left side, that would explain this effect.
The same applies if your up movement is not actually straight up. Depending on how you implement your upwards movement, applying gravity will cancel out all upwards components of the movement and pull the particles down, but if they have a leftwards component in their movement, that will continue to apply and result in the particles drifting away.
I am building a flappy bird game where half of the level is above water, and the other half is below water.
If your bird is in the air, there is regular gravity and when you tap, an impulse is applied going straight up.
If your bird is in the water, gravity should be in the negative direction (going up) and be less. When you tap, an impulse is applied going straight down.
Can I set a scene's gravity in different places?
I thought of using a timer to apply negative forces if the bird is in the water, but it's all over the place.
Also, I can't just change the entire scene's gravity because there are other SKSprite objects in the scene that should have different gravity applied to them (for instance one bird in the air should be flapping up when tapping, and a bird that dove into the water should be swimming down when tapping all at the same time).
Gravity is the same throughout the world, so you can't have areas of different gravity.
However, just because SpriteKit doesn't offer a higher level abstraction for something doesn't mean it's difficult to do for yourself. SpriteKit's constant gravity does the same thing to a body as if you apply a force to it with the same magnitude and direction every time your scene's update: method runs.
So, you can do different gravity in the upper and lower parts of your scene in your update: method.
Check the y-coordinate of your bird.
If it's below whatever threshold separates water from air, use applyForce: to apply an upward force. If it's above the water, apply a downward force.
Because this happens every frame, the bird will accelerate downward when above the water and upward when below, and you should see a nice loss of momentum effect just after the transition.
You'll need to tweak the magnitude of your forces until it behaves just right for the gameplay you want. When you do, be aware that the units for applyForce: are 150x those of SKPhysicsWorld's gravity (because of what's probably an Apple bug) and depend on the mass of your physics body (because of Newton's second law).
I have an idea for how you can do this:
make two rectangles for the top and bottom half (one for water, one for the air)
create a physics body on each rectangle that simulates the gravity you desire
set those rectangles as the contact delagate
add the other objects to the rectangular world they should be in
To handle main bird:
- When the anchor point (probably set in middle) contacts one of the rectangles,
change the contact delegate of the main player from the first body to the second body in the contact event.
This means that you have two worlds with different gravities with a main character who's gravity switches among contact of a new world(passing through the middle)
Good luck
I am working on a game which has working similar to game monkey kick off. I have one ball bouncing on a place at the left side of screen and depending upon the position of the ball I apply linearImpulse to the ball on user touch so that it appears that the ball is kicked.
But what happens is when i apply impulse the ball goes out of the screen bounds. I dont want the ball to go out of the horizontal screen bounds whereas it can go out of the screen vertically.I tried using CCFollow but it doesn't give the realistic feel to the game flow.
I tried THIS tutorial, but dint help much.I managed to scroll the background,Only this part remains.
Any Ideas on how the ball should not move out of the horizontal screen boundary..? but in case of vertical boundary on the other hand it can go out of the bounds.
If you're not using physics, it's a simple bounds check. Assuming the screen width is 320 points this will keep the ball inside the screen horizontally:
CGPoint ballPos = ball.position;
ball.position.x = fmaxf(0, fminf(320, ballPos.x));
ball.position = ballPos;
UPDATE: I noticed you mentioned linear impulse. So you're using a physics engine. In that case, create a horizontal wall on both sides. See the cocos2d Box2D or Chipmunk templates how to enclose the screen with a collision border, then use only the left and right side borders in your game.
Hi guys I Am developing the application in cocoas2d using the box 2d frame work but unfortunately
i'm not able to restrict the gray ball in the half screen area of the image shown here
i want that ball not to go opposite part of the screen
I Have Used The b2Mousejoint For to move the ball around the screen
b2PrismaticJointDef restrict on any particular axis
But
i want to restrict on the particular rect area of the screen
You could create your custom distance joint which will restrict global axes of the ball. But it will be hard if you never write your own physics engine.
There are 2 easier ways to implement what you want.
Create 4 static "border" boxes around the area where the ball must stay. Then place the ball and the boxes into one collision group.
However, the response of the "border" boxes will not be instant. Therefore, the ball at high speed will sometimes "sink" into the boxes, then be popped out.
You can correct the position and reset the speed of the ball manually in code when it crosses the bounds of the desired area. But it may lead to the unstable physics simulation.