I am looking for a way to make my game load more SKScene when my node (ball) goes above certain Y position.
I'm looking for a way to make the loading a little bit like ColorSwitch game where you tap and the ball loads more screen once you hit a certain Y position.
Use SKCameraNode and have it centered on your scene (or wherever it is you want to look at). Check documentation or search here for more help on setting up your camera.
In update() simply check the position of ball's y value ball!.position.y, if it's past a threshold such as view!.bounds.y, move your camera up by however much camera!.runAction(SKAction.moveBy...)
If you want to scroll back down, it would be a bit more complicated, but the same principles would apply.
(note: I have my stuff as Optionals so your code may not have !)
https://developer.apple.com/reference/spritekit/skcameranode
You could also use invisible boxes and collision detection, but that seems more complicated of an approach to me >.>
If you post some code we can help you get it up and running. Unfortunately, there will be some degree of math involved x[
Related
Both hand with disappear in the game and scene if i get close enough or look at them any solution. m using unity URP:
it only happens when using animation rigging
Make sure the bounding boxes (i.e Bounds) of your SkinnedMeshRenderers are set to correct dimensions. Culling decisions are made based on those boxes. If they are too small, the mesh might get culled even if it's still visible.
You can also check "Update When Off Screen" to have the bounds updated while animating. This does come at a slight performance cost however, so see if it's suitable for you.
I want to make a terrain where the ending point is also the starting point. So, like on the earth you could just go on walking straight and you would reach the point where you started again after some time.
Thanks for your help!
Unity's Terrain system can only create square regions of terrain. So this can't be done as such.
However, you can approximate it, and I'll tell you how I've done it in my project to some success.
Figure out how much terrain you need to cover the "globe", we'll say it takes NxN chunks of terrain we'll call a "tile".
What you do next is you make 9 of those NxN tiles, and arrange them in a 3x3 grid. Put the camera in the center tile of the grid, and whenever the camera leaves that tile, determine where it is on the tile it is on, then change its position to the corresponding position on the center tile.
This will give you a "toroidal" world. I found this was the easiest solution to get the player to see things on the other "corner" of the world map, and then cross into it without graphical issues.
If you have other objects residing on the world, that presents some additional challenges. One thing you can start with is duplicating them 9x and start them at the same relative position of each tile. If they only interact with the player, that should be fine, just whenever the player interacts with 1, the other 8 do whatever that 1 does.
If the other residents of the globe have to interact with each other, you'll need a way to figure out how to make all 9 copies of everything behave consistently, but that's too broad of a question to address here.
How would i go about creating as a background for a 3d scene a plane with a texture that stretches into the horzon? I have tried a skybox but i think a skybox will also be needed "behind" the infinite plane.
It depends whether you need to have an actual geometry that will be seen from close up - if not, you can bake it into the skybox.
In some cases (i.e. when the user has stereoscopic display on their head) you will need to have actual geometry.
Its not exactly clear from your question if you want to create a 'floor' or a 'wall', but in both cases I would link it with player position somehow. A floor could follow players X an Z, while a 'wall' could be made a child to the camera, this way it would never leave the viewport.
Skybox would still be the cheapest by a significant margin, we can give more advice if you provide some additional information. i.e. what are you trying to achieve
I was making a test "breaker" game in SceneKit and tried speeding up the ball. At a certain point, the ball would consistently pass through my boundaries. Not quite sure why, I slowed down to 1 FPS and took this screenshot:
When looking at Apple's docs:
A small body might move so fast that it completely passes through
another physics body without ever having a frame of animation where
the two touch each other.
However, it is
clear that the ball is touching the boundary, yet still passes through. The contact delegate will also register a collision. This is with an x-velocity and z-velocity of 50-100 each. Shouldn't this scenario cause the ball to bounce back, as the frame rendered with the ball touching the obstacle? And along with this, how would I check super fast collisions as such in SceneKit? I heard that in SpriteKit, one can use usesPreciseCollisionDetection, but this doesn't seem to be the case in SceneKit.
To give an exact idea of what the boundaries look like, they are two cylinders with no space in between.
Edit: Seems like changing the physics shape on the boundary to either convex or concave instead of bounding box helps, but does NOT completely prevent a contact registering but a collision not happening. Same if I create a new obstacle - it'll pass through at high enough speeds while still registering contact delegate. Any theories on why?
Edit 2: From the comment on this question, here is a screenshot of where didBegin is called by setting a breakpoint. You can see that the ball is just leaving the barrier. It starts passing through when x-velocity or z-velocity is set to about 29-40 and is completely unreliable as to whether it passes through or not after that. Always though, didBegin is called, but not always didEnd
I have a simple project built with Cocos2D and Chipmunk. So far it's just a Ball (body, shape & sprite) bouncing on the Ground (a static line segment at the bottom of the screen).
I implemented the ccTouchesBegan/Moved/Ended methods to drag the ball around.
I've tried both:
cpBodySlew(ballBody, touchPoint, 1.0/60.0f);
and
ballBody->p = cgPointMake(touchPoint.x,touchPoint.y);
and while the Ball does follow my dragging, it's still being affected by gravity and it tries to go down (which causes velocity problems and others).
Does anyone know of the preferred way to Drag an active Body while the physics simulation is going on?
Do I need somehow to stop the simulation and turn it back on afterwards?
Thanks!
Temporarily remove the body from the space.
If you want the object to have inertia when you release it, that's a different story. The cleanest way is to attach a fairly stiff spring between the ball and a temporary sensor body that moves under the control of your finger. When you let go with your finger, the ball will retain whatever kinematics it had while you were dragging it. Be sure not to remove the ball from the space in this case.
You aren't updating the velocity of the object when you aren't using cpBodySlew(). That is why it falls straight down.
A better way to do it is to use a force clamped pivot joint like the official demos do to implement mouse control. http://code.google.com/p/chipmunk-physics/source/browse/trunk/Demo/ChipmunkDemo.c#296