Search Knowledge Base by Keyword
Interacting with strange, cute or fantastic characters that seem to be in our real world is like a dream come true. In this demo you can interact with a little bird that’s hopping all over the place. We suggest you read first how to create interactivity with SpatialStories and how to place objects in AR to fully understand this tutorial.
For this demo we use the Object Mover Behaviour.
We are going to place a shadow plane on which the bird will be hopping. We will also need some targets in the space where he is going to fly and of course the bird itself.
1) Get your assets ready: the model of the bird is an .fbx with animations coming directly from Maya. In Unity all you need is then an Animator Controller component where you create the state machine for the different animations he will perform.
Our toolkit reads the Trigger transitions of the Unity Animators. Here we need a Fly trigger to launch the flying animation (composed of 3 clips).
Targets: we want the bird to fly to random locations (among specified ones) when we approach him. For this create an object with target objects (empty Game Objects) inside, you can also put a ShadowPlane to have shadows on the floor. Targets are placed around the center, at about 1.5m from it:
This is the Targets hierarchy:
2) Create an Interactive Object for the bird: drop the model in your scene and then convert it into an Interactive Object (see how)
3) Set the conditions: you can rename the Empty interaction as you wish, here we named it BirdFly. The condition for the bird to fly will be when the user approaches him. For this we use the Proximity condition with OnStay mode between the smallBird(IO) and the Head (IO). Make sure that Proximity colliders are in a good position and of a proper size to make sure the collision with the head is done (see image below).
As we want the bird to be flying away everytime we approach him (you could choose another behaviour of course!), we want this interaction to Reload infinitely. However we don’t want the bird to change direction while going to a specific point so we put a Delay of 5s in order to wait until he has done all the animation and is back to Idle.
4) Set the actions: What we want to happen when we approach the bird is for him to perform the flying animation, In the Actions section we just setup the Animation on MECANIM mode (Animator) and chose the trigger Fly. But we also want the whole Game Object to go to some targets in the space otherwise the bird won’t really change its position. For this we add a Custom Action (CA_MoveToRandomTransform).
5) CA_MoveToRandomTransform: this is for the bird to fly to the different targets everytime we approach him. We need to specify the target transforms in the space to where the bird will fly (position of course will be relative depending on where targets will be spawned). We take the four target objects we created and put each one inside the slots of the Target Objects. The animation time is the time for the object to move to the next target. The bird will be facing the target position and the other options are not needed in our case.
6) Placing Objects: we are going to use the Object Mover Behaviour, this allows to place objects that have interactions or that have a link with positions and with other Interactive Objects.
In this specific case our bird is himself an Interactive Object, and then the targets to where he goes need to be in the scene because the Custom Action needs them as a reference.
This is the behaviour setup for the bird. Our cursor is named KokoCursor (it’s the bird with a circle at the bottom).
For the targets, do also a Mover Behaviour, the targets will be placed at the same time as the Bird. The ShadowPlane prefab inside makes shadows appear on the floor.