Using physics with String AR

Hi all,

This is a response to a question in another thread- basically, “how do you use physics with String”

All versions of String should come with two camera managers scripts, one called
CameraCentricARManager.cs
and
ContentCentricARManager.cs

The one you’ll want to use is “ContentCentricARManager” but the best way of setting it up isn’t 100% obvious.

Basically, CameraCentric requires you to point the script at a root marker gameobject, which usually you parent the reset of your scene to. The script then moves the gameobject (and everything under it) around your camera, which sits statically in space. Obviously if you have physics enabled, the moment you do that, everything will go flying everywhere (if indeed it doesn’t the moment you press play, depending on the direction of gravity).

ContentCentric on the other hand manipulates the camera to move it around the scene- which obviously makes a lot more sense for most Unity applications, but is slightly harder to set up.

To set it up:

  1. Add a Unity plane to the scene (don’t worry about the number of vertices, etc, as it won’t be drawn).
  2. Remove the collider from the plane (if it exists).
  3. Rotate the plane to (270,0,0) (This is assuming your marker will be sitting on for example a coffee table, and you want gravity to be downwards)
  4. Set the transform position x,y,z of your plane to be (-1.4,0,0); basically you want to move the plane so that it’s centre is exactly where you want the centre of the marker to be. You can fiddle with this a bit, but this is a reasonable default.
  5. Add the ContentCentricAR.cs script to your camera
  6. Add a reference to the plane to the ContentCentricAR.cs “Marker Objects” array. (be sure to ref the one in your actual scene)
  7. You can uncheck the MeshRenderer on the plane. (I leave the component on though as it’s sometimes useful to see where it is)
  8. You can manipulate the scale of the scene from the AR perspective by simply adjusting the scale of the plane. Initially, if you populate the scene with standard unity cubes etc for testing, I’d suggest setting the scale to (0.1,0.1,0.1)

That’s it really. Your camera will now move around the scene, and physics will be sensibly downwards.

One thing though, if you tilt your marker, stuff won’t fall off, and if your marker is attached to a wall, things (if setup like above) will fall towards the wall :slight_smile: I’ve tried other approaches where you actually manipulate the gravity vector, but given additional variables like the IOS device’s orientation and physics not liking gravity to move, I’d really not recommend it :slight_smile:

Post questions here if anyone has any problems.

Results of this method here:

I’m easiest to get hold of on twitter via @runonthespot for any further questions on this.

Thanks for posting this up. Having a hard time finding any kind of dev info on String. And with a name like String it’s impossible to search for!

Assuming I can get past the StringWrapper.cs error I’m having, I’d love to play with this. :thumbsup:

Yeah, agreed. Thanks for posting. I was getting frustrated trying to get my model to orient correctly til I read this.

Pleasure. I’ll be posting a proper tutorial on my website which is currently being built so watch this space. Tutorial includes a character controller and iOS ready tap-to-move with Contentcentric setup. I’ll also be posting up my voxel like cube experiment.

PixelPlacement aka Bob Berkebile has put up a great free add-on to String to manage you camera more easily. http://pixelplacement.com/2011/07/14/introducing-string-manager/ Worth checking out if you’re experimenting with string right now.