Item Swapping, How to?

Hi Guys,
I want to be able to swap between items in the player, but I am having trouble doing this.

I have a button in the interface and when the user presses on it, it should hide the current item and reveal the next. I have tried various different ways to acheive this but I can’t understand the logic. Please see the attached project that contains some simple dummy objects and an interface.

Could someone point me in the right direction?

Here is the project file I have been working on:

[Your file “AR-itemSwap_v02.zip - 1.3 MB” is ready for download: https://share.theimagefaculty.com/_ZsJFIKQpMZYV5R](Your file “AR-itemSwap_v02.zip - 1.3 MB” is ready for download: https://share.theimagefaculty.com/_ZsJFIKQpMZYV5R)

Thanks,
D

Hi Darren,

I’m assuming you want to do this with only 1 UI element.
An easy method to achieve this is to set the flags of the layer that contains your models as a local timeline & local status as well as checking the loop checkbox.

You would then place your models in the layer for a specific time. Let’s use 1 second for example. To do this, in the timeline, set your model’s end time to 1 second.

The second object should start when the first one ends. Do the same for all the models you want to include in your scene.
Your timeline should look like stairs.

Playing your scene will show 1 model at the time for 1 second and loop.
You now need to add a constraint to prevent the scene from switching to another model when you’re not clicking on your UI element.

You can do this by adding a timeline jump to action for each models that you placed in the scene.
The first one should start at 0.9 and end at 1. In the parameters of the action, set the time to 0.

Now every time you’ll play the scene, when the time hits 0.9 seconds it will go back to 0 seconds.
You need to copy paste this action for all your models in the scene and position them accordingly in the timeline.
The only thing you need to change is the time the action will jump to.

For example if your second model starts at 1 and ends at 2. The parameter of the second timeline jump to should be to jump to 1 and so on and so forth.

The next thing you need to do is to use the action that adds time to a timeline incrementally, I think its name is timeline add time or something to that extent (@pierre, can you confirm the name?).
You would use this action on your UI element and target the layer containing your models.

Every time you click on it, it will add 1 second to the layer so you would only be seeing the model that is active during that time. Since you would have constraints in place, the time during which the model is active will be looped indefinitely until you click on the UI element again.

The last thing you need to do is to create a last timeline jump to starting at the end of your last 3D model. Make it last for 1 second and set the time to jump to 0. This way, when you have clicked all the way until the end of the timeline, the last click will bring you back to the beginning.

I’ll send you an example using your scene as a base shortly.

Cheers,

Following up on Louis’ advice:

Here’s a screencap of how you could set it up (project attached below):

The project: AR-itemSwap_v02.zip (1.3 MB)

The key points:

  • The models are laid out sequentially on the timeline
  • The Models dummy entity is used as a container, its set as “LocalTimeline” & “LocalStatus” so that it loops and stays visible independently of the global timeline
    image
  • TimelineJumpTo’s are used to keep a single model visible at a time
  • TimelineJumpAdd is used in the button to move to the next state
  • A “BackToBeginning” TimelineJumpTo is added after the models so that it jumps back to the first model once we reached the end of the list of models.

Let me know if anything isn’t clear or need more explanation :slight_smile:

1 Like

A small gif of how it looks in action:

That’s great thankyou guys.

I was trying to animate the entity enable / disable action using jump to’s, but wasn’t successfull.

I follow your technique on a new scene and see if I can get it to work for me.

Cheers,
D

It is one of many techniques :slight_smile: Lately i’ve been using the EnableAlone(Action) for similar tasks - mostly changing menu pages. EnableAlone works by disabling all except the target under the same parent.

Models(Dummy)
-SphereBlue(Primitive)
-SphereGreen(Primitive)
-Box(Primitivie)

If you target any one of those with EnableAlone(Action) the rest will be disabled. You could create a list of buttons too in the same fashion so that each button corrisponds to a specific model you want to show.

With this method you don’t need to do a lot of timeline adjustments but it does require a little more (easy) setup. Mostly copy/paste.

There are many other ways but they can be a bit convoluted.