Menu and ItemSpawner issues

So I tried to mimic the Litho City Builder and extend it to AR Gardens concept. Here is a video of what I tried. Here are two issues that I faced -

  1. Notice when I walk towards the blue panel, it moves away from the camera, as if it’s not fixed in the environment. I have placed in the same hierarchy as the Showcase prefab in the Demo Scene. But I still faced this trouble. What should I look into to resolve this issue?
  2. The models in the blue panel have a very small size. It’s not flexible. Digging into the ItemSpawner (in the FixedUpdate() method) script I noticed that the scaling factors are hardcoded. Maybe the sdk can provide a more customized solution to that like giving the developer to control the size of the icons? We can have two sizes. One inside the panel and the other when the model is popped out of the panel. This should provide the flexibility of testing the sizes while developing.

As this project was a part of a Hackathon you can also find the code in this repository. The AR Farming module contains the Augmented Gardens Unity Project. The other modules are part of the core application developed in Flutter. We changed the name of the project from AR Farming to Augmented Gardens later on in a rush so please don’t get confused due to that.:sweat_smile:


Hi Rajat,

Great to see another project coming together! Here are some pointers:

:bulb: - It looks to me like the blue panels are in fact fixed in the environment, but they are further away (and larger) than they appear. They appear to move away from the camera due to a parallax effect (imagine walking 10 steps towards a building that is a mile away from you - the size would not appear to change significantly).

:point_right: - My first suggestion would be to make the blue panels smaller, and make sure they are within 3-5 metres (specifically for the test environment from the video) of the ARSessionOrigin.

:bulb: - I believe the icon size of ItemSpawner can be controlled directly by changing the scale of the ItemSpawner object itself (as the hardcoded value refers to the localscale of the icon transform, and the icon is a child of its ItemSpawner). The Item Container Prefab of the ItemSpawner may need to be modified or removed to support tall or wide objects (such as flowers), as the default SpawnOrb prefab is designed for objects with similar x,y,z dimensions (e.g. cubes). The miniature object placed inside the Item Container Prefab (SpawnOrb) is scaled so that its bounding radius fits within the container.

:bulb: - When an ItemSpawner spawns an object, the new object will be scaled to match the prefab it was created from. This means you can easily change the spawn scale by modifying the prefab scale. Note that the scale of the new object will also be affected by the scale of the Spawn Parent that hosts it, if a value was provided to the ItemSpawner.

:thought_balloon: - I think these points should solve your issues, however since there are some more complicated cases that cannot be implemented with the current system, I have opened a feature request to be considered in a future update - thanks for the suggestions! :slight_smile:

Thanks for providing so much detail too!

Also, I’ve split this topic into a Support thread and a Made With Litho thread.

1 Like

Thanks for the detailed answer. I was able to solve the parallax problem. The panels look good now.

I am just stuck with the size of the ItemSpawner though. I modified the scale of the prefab and the ItemSpawner should scale it up but it doesn’t

I just downloaded 0.4.3 and noticed that the ItemSpawner now has a parameter "Spawn Prefab Scale Factor". I guess since the flowers are tall and thin, it’s bounding radius is getting adjusted such that the SpawnOrb is containing it. Due to this, the flowers are looking very small.

I also checked out this new Furniture video and noticed that there is no spawn orb in the panel. When I set the IconContainerPrefab to None then infinite instances of the SpawnPrefab keeps spawning inside ItemSpawner.

1 Like

Hi Rajat,

Glad you sorted the parallax issue, and thanks for upgrading so promptly!

:bulb: - To be clear, both changing the prefab scale and changing the new Spawn Prefab Scale Factor field will only affect the scale of spawned objects - the icon size will not be affected.

:point_right: - If you want to change the size of the icon, scale the ItemSpawner object.

:thought_balloon: - The other point you noted about the Icon Container Prefab is a bug which I’ve been able to reproduce and have logged in our tracking system - this should be fixed for the next release. For now, see the point below:

:point_right: - If you want to hide the orb: clone the SpawnOrb prefab, disable the MeshRenderer component on the clone, then set the clone as the Icon Container Prefab on your ItemSpawner object.

Let me know how you get on :slight_smile:

When I scale the ItemSpawner object the SphereCollider(that is being added to the ItemSpawner via the ItemSpawner script, check lines 199-203) collides with the other ItemSpawner s in each row. This results in displacing the objects out of their respective positions.

I was able to hide the orb by disabling the MeshRenderer component that you mentioned. Neat little hack that I use most of the times in my projects. Hehe :stuck_out_tongue:

I have uploaded the project to this repository. Let me know if that helps.

1 Like

Right, I see your issue. I have flagged this internally as an additional point to the other ItemSpawner issue, both of which should hopefully be fixed as part of the next SDK release. For the time being I can think of two options:

:one: - Space out your menu items such that they don’t collide with each other.

:two: - Clone the ItemSpawner script, and use this clone for your menu items. In the cloned script, modify the lines you mentioned (199-203) to look for Collider instead of SphereCollider - this should allow you to put any type of Collider on the Icon Container Prefab you use. This is likely to be the sort of fix I will include in the next update, however, until then, I won’t be able to support it.

Yeah I was going to change the ItemSpawner script but then I thought I should ask if there is something else in the SDK that I am missing perhaps. Cool then. I will try to modify the script. Incase I fail I will just go with option 1 most probably.
However I am wondering how was the same thing implemented in the City and the Furniture simulation? Is there something else that was added or modified maybe?

1 Like

Thanks again for checking first - it’s super helpful to hear what our users expect from the SDK :slight_smile:

:exclamation: - Please note that for any scripts you modify, you should be sure to first clone them into your Assets folder and give them a new name. Failure to do so may result in your modifications being lost when you upgrade your Litho SDK (or, if you are using version control, there may be unresolvable conflicts).

:bulb: - The City builder has some additional custom modifications/ features that are incrementally being added to the SDK. As discussed, better ItemSpawner flexibility is on track to be added soon, and there are other familiar City Builder features that we plan to add.

1 Like