The O.G. Virtual learning! Buy one, get 2 more Lifetime Memberships! - Click Here!

Ball toss through Z Space in ARKit using SpriteKit

Home 4 Forums Swift and Sprite Kit Ball toss through Z Space in ARKit using SpriteKit

Tagged: ,

This topic contains 5 replies, has 2 voices, and was last updated by  Walter Ragland 3 years, 10 months ago.

  • December 6, 2017 at 9:17 pm #177028

    Hi Justin!

    Looks like my previous post didn`t take so if this comes out as a duplicate, I apologize.

    Im really wondering how you are getting that 2D ball to fly through Z-space to clear those hoops and hit those birds in your SceneKit/ARKit demo ( ) . Ive learned how to do this in SceneKit using ARKit, but I haven`t found any tutorials on how to do this in SpriteKit using ARKit yet. Could you share the code or create a quick tutorial on how to do toss an object along the Z-axis in SpriteKit/ARKit?

    Im planning to use SpriteKit for my next game because I want to use forward facing 2D graphics instead of 3D, but for throwing projectiles, I dont think I can shrink the graphic while making it fall with gravity until it hits something because the ball/projectile would still appear above all of the other background graphics on different Z levels, correct?

    I haven`t started coding the came yet, just planning it right now. This is connected to my previous question as well.

    Love that demo. šŸ™‚

  • December 7, 2017 at 2:20 pm #177046

    sprite kit arkit make object go through shape

    Sure so one important thing is the physics body can’t be a donut if you’re sending a ball through something like a ring. You have to leave a small gap in it like the image above. The sprite itself can look like whatever you want though. If you want to test that the ball went through the ring, you can have a separate physics body (just a circle shape) within the ring that’s used for contact detection to score points or whatever.

    The z layer really doesn’t have much to do with it because that gets ignored (mostly) once things are in the AR world. Its the zDistance from the user in augmented reality thats important.

    But what I would do is launch the ball toward the targets in the normal non-AR scene, then at a certain size that ball is removed and replaced with a ball thats put into the AR world at a zDistance in back of the targets. Its what I did in my Tooniverse app and its really convincing.

  • December 7, 2017 at 8:08 pm #177058

    Ok, I think I have a general idea of the concept now.

    I didn`t know that you had already released the Tooniverse app. Just downloaded it and have been playing it this morning.

    To be honest, this is the most fun, reliable and interactive AR app that I`ve played on from the App Store so far next to Stack, BB Zombies and Kings of Pool!

    Ive built some of the standard AR Apps (like AR drawing, 360 alien shooters, the Ikea App and a few others from the Udemy courses Im taking this week) for study in SceneKit with AR, but these are the types of games that I prefer. The plane detection and tracking required for placing 3D objects is a little too hit and miss while indoors for my tastes depending on the device being used. These games require too much space and movement for the types of games I have in mind.

    I think its probably frustrating for users, so Id prefer to work more with SpriteKit and AR style games similar to Tooniverse until things get a bit more stable on the plane detection side. But there are very few tutorials on building actual games AR Games with SpriteKit – just yours!

    Been going through your notes and blog posts to see if I can find sample code for the ball toss and layer interaction, but basically you are using a technique similar to this in the beginning and just switching the graphic & zDistance after the ball shrinks to a certain size, correct?

  • December 7, 2017 at 8:17 pm #177059

    Btw, for the second part of the ball toss, you`re referring to removing the sprite based on zDistance as the ball moves away from the player, as in this tutorial, correct? “Collecting or Removing Sprites Based on Z-Distance to the Camera”

  • December 7, 2017 at 8:48 pm #177060

    Ahh, well if the ball doesn’t have to actually look like its going through something (like a ring), then my original reply is a bit off topic.

    If you’re just tossing the ball into a trashcan, I think you could just add the sprite straight into the AR world and make it appear like its being tossed forward by shrinking it adding gravity.

    Thanks for the comments on the game. Be nice if Apple’s editors took notice too =)

  • December 7, 2017 at 9:20 pm #177061

    Good timing. I just left a review of your game about 5 minutes ago.

    No, you were correct. My projectiles (ninja stars) will need to go through hoops and objects to hit their targets so the obstacles will be a major factor.

    Im actually very surprised I havent seen this game featured anywhere on the Top 10 AR Kit games lists anywhere ( I was looking for it ) because your video demo was what made me want to study in-depth AR in the first place and the video has been out for awhile… I just thought you hadnt released the game yet for some reason and were waiting until your AR Master Course was completed or something so thats why it wasnt on any of the lists... Hahahaha! But most people arent teaching SpriteKit with ARKit for some reason.

    Was pretty shocked to see that it hasnt gained so much activity or reviews on the store yet. Maybe theyre only considering SceneKit 3D based AR games?

    But to be honest, Im not really too impressed with most of the 3D games that Ive seen and am learning to build so far. I think SceneKit and 3D is good for some apps, like Stack, Educational apps and the Ikea app that won`t require so much movement, but for high-speed interactive and fun games… Hmmm probably need to wait awhile on those until the plane detection & lighting technology can be improved…

    I bought 3 AR courses though, so I should be a SceneKit professional by the end of this month though, even though they dont cover SpriteKit with ARKit much - which is what Im really interested in.

You must be logged in to reply to this topic.

Know what an affiliate program is? You make money just by sharing links to our site! Win. Win.

Earn when you refer any buyer here! 30 day tracking. Commissions are 33%-50% and recur on subscription products!

Uh oh, missing your affiliate ID. Create one real quick