Giter VIP home page Giter VIP logo

arshooter's Introduction

ARShooter

License

ARShooter is an open source Augmented Reality shooter made with ARKit and written in Swift. Hence, it is only useable with iOS 11.

For more details on how to get started with ARKit and make your own AR Shooter, take a look at the complementary (and complimentary) tutorial.

status

Requirements

  • Xcode 9
  • iOS 11
  • A9 or better chip for ARWorldTrackingConfiguration

Note: The app automatically detects if your device supports the ARWorldTrackingConfiguration. If not, it will use the less immersive AROrientationTrackingConfiguration, which is supported by all devices.

Communication

  • If you found a bug, open an issue after checking the FAQ.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Download

Simply navigate to your directory of interest, then clone.

$ git clone https://github.com/farice/ARShooter.git

If you'd like bullets to disappear rather than collect in the space around you, then switch to the bullets-disappear branch

 $ git checkout bullets-disappear

Finally, open the *.xcodeproj file and build to your supported device

FAQ

I am getting the SCNMatrix error:

Cannot invoke initializer for type 'SCNMatrix4' with an argument list of type '(matrix_float4x4)'

Please update to the latest Xcode version (this error is a result of a syntactical change made in Beta 2). If you insist on using Xcode Beta 1, then simply replace SCNMatrix4 with SCNMatrix4FromMat4.


Thanks

ARShooter has been featured by

License

ARShooter is released under the Apache license. See LICENSE for details.

arshooter's People

Contributors

farice avatar wave-electron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arshooter's Issues

iphone6

hey, i'm just having a black screen, with the box(picture) and i can shoot but nothing else, nothing is moving either

Tranform matrix help

Awesome Repo. Thanks! I'm looking for some more information around the "getUserVector()" method.

Firstly -- SCNMatrxi4.mat31, mat32, mat33, etc. are not available anymore. Xcode shows me that I must use SCNMatrix4.columns.1.x, which Is confusing -- I don't know how to convert to the m31 matrix syntax with the new columns approach.

My main issue is that I'm having a real hard time finding in the Apple docs what exactly all 16 elements represent in the 4x4 transform matrices, for example the ARcamera.transform matrix. How did you know that m31, m32, and m33 are the orientation of the camera, and that m41, m42, m43 are the position? Lastly, as mentioned above -- these coordinates would need to be converted to the new columns.0.y syntax, which again seem to be poorly documented in any apple doc. I feel like I'm missing some holy grail for Matrix Transforms from apple.

Thank you so much!

func getUserVector() -> (SCNVector3, SCNVector3) { // (direction, position)

  if let frame = self.sceneView.session.currentFrame {
  let mat = SCNMatrix4(frame.camera.transform) // 4x4 transform matrix describing camera in world space
  let dir = SCNVector3(-1 * mat.m31, -1 * mat.m32, -1 * mat.m33) // orientation of camera in world space
  let pos = SCNVector3(mat.m41, mat.m42, mat.m43) // location of camera in world space 
   return (dir, pos)
  }
   return (SCNVector3(0, 0, -1), SCNVector3(0, 0, -0.2))
}

Remove old "bullets"

Is there a way to remove old bullet nodes? I have been looking around the project and can't seem to figure out how to do it. Without this functionality, there are a bunch of "bullets" flying around.

Touch to shoot anywhere?

Possibility to shoot where the screen was tapped and add a small amount of gravity? I tried adding it but it was a dramatic drop.

Error SCNMatrix4(frame.camera.transform)

let mat = SCNMatrix4(frame.camera.transform) // 4x4 transform matrix describing camera in world space

Error:
Cannot invoke initializer for type 'SCNMatrix4' with an argument list of type '(matrix_float4x4)'

I get this error when I try to build your project on my machine.

Matrix Error

Just forked and receiving:

Cannot invoke initializer for type 'SCNMatrix4' with an argument list of type '(matrix_float4x4)'

Played around a bit with manual init, but not keen on extracting and typing the variables.

sound effects enhancement

A simple enhancement is adding sound effects using AVFoundation. I added 3 basic sound effects, torpedo.mp3 (bullet sound), explosion.mp3 , collison.mp3.

sound effects available:
torpedo.mp3
explosion.mp3
collision.mp3

import AVFoundation
var Player: AVAudioPlayer = AVAudioPlayer()


// added this basic code snippet in three places just change the forResource for each mp3 name.
do
        {
           let MusicURL = Bundle.main.path(forResource: "torpedo", ofType: "mp3")
            try Player = AVAudioPlayer(contentsOf: NSURL (fileURLWithPath:MusicURL!) as URL)
            Player.prepareToPlay()
           Player.play()
        }
        catch let error as NSError {
           print(error.description)
       }

1st spot. after

@IBAction func didTapScreen(_ sender: UITapGestureRecognizer) { // fire bullet in direction camera is facing

2nd spot. after


 func removeNodeWithAnimation(_ node: SCNNode, explosion: Bool) {
        
        
        if explosion {

3rd spot after

 func physicsWorld(_ world: SCNPhysicsWorld, didBegin contact: SCNPhysicsContact) {
        //print("did begin contact", contact.nodeA.physicsBody!.categoryBitMask, contact.nodeB.physicsBody!.categoryBitMask)
        if contact.nodeA.physicsBody?.categoryBitMask == CollisionCategory.ship.rawValue || contact.nodeB.physicsBody?.categoryBitMask == CollisionCategory.ship.rawValue { // this conditional is not required--we've used the bit masks to ensure only one type of collision takes place--will be necessary as soon as more collisions are created/enabled
            do
            {

Thats it!

iPhone5s crash

2017-06-07 18:40:19.329904+0800 ARViewer[771:115352] -[MTLTextureDescriptorInternal validateWithDevice:], line 778: error 'MTLTextureDescriptor has invalid pixelFormat (520).'
-[MTLTextureDescriptorInternal validateWithDevice:]:778: failed assertion `MTLTextureDescriptor has invalid pixelFormat (520).'

on iPhone5s , but iPhone5s simulator is ok

Camera Transform Matrix Values

Hi, I was looking for ways to implement projectiles in my ARKit project and stumbled across your ViewController. I saw that in the method getUserVector, the direction property was set based on positions: m31, 32, and 33 of the camera transform matrix and I was wondering how you figured this out. I wasn't able to find it anywhere I looked in any documentation, article or video. Is there some sort of documentation on the properties of this matrix you found? Sorry to open a new issue. I hope I'm not bugging you, I was just insanely curious about that one line (which helped me a lot, thank you!).

Cheers, Harry

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.