ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Announcements and Showcase
forum topic indicator make a shopping system
person icon
19kind
Registered User
Quote
2024-09-20 03:09:54

I want to make a shopping system. How to display the items in scene 1 in scene 2?

person icon
guest_guest
Registered User
Quote
2024-09-20 15:26:11

Hi 19kind,

It's a pretty vague description tbh. It depends a lot on what exactly do you want to do.

For example, you start with exact description:
1. I start shop scene
2. I buy a weapon
3. I quit shop scene
4. I now have that weapon added to my fps camera view

That is goal decomposition. Now you have a lot of small problems instead of one big.

Then you go one by one:
1. You create a separate scene for the store. Add some 2d overlays for different weapons.

2. How do you buy a weapon? Probably you do left click on the image. Now if user left clicks on the item, how do I know user now have it?

You can utilize a variable for that. Name it currentWeapon, set it to values specific for different types of weapons:
0 for pistol
1 for machine gun
2 for shotgun etc

So add action on click to each of weapon 2d overlays -> set variable "currentWeapon" to 0, 1, 2, etc respective to what overlay user clicks.

In order to make it a shop, not just select menu you also need money. Once again you can utilize variables for that. Add "before first draw" behavior to the root node of any scene and create another variable like "currentMoney" set it to some value, like 100.

Now you need to decrement that variable every time user buys weapon. I don't quite remember how it is done without coding, but there should be a way to do it using "set variable" action.

The last one thing is to make sure user is not able to buy item which is too expensive. For that you need to put "if variable has value than do" action before assigning "currentWeapon" variable, and make sure weapon price is less or equal to "currentMoney".

3. User quits shop scene buy buying any weapon. So just add another "switch scene" action to the existing "on click" action which you have for any scene node.

4. It's easier to hide/remove stuff from scene than to create it. So add all weapon models to your fps camera first. This step is actually tricky without coding, but you can use something like "Every few seconds do something". Attach it to the root node, set interval to some low value like 100ms or even lower. Now add "if variable has value than do" and hide all weapon nodes which are not supposed to be shown based on "currentWeapon" variable value.
So if currentWeapon === 0 - hide machine gun and shotgun, if it's 1 - hide pistol and shotgun and etc.

Pretty much the same logic based on variable works for shoot action, basically you can choose which shoot action to execute based on variable property.

Also, you can easily search forum using google. For example: https://www.google.com/search?q=...

Or you can ask ChatGPT, like "Could you search wwww.ambiera.com/forum.php" for any threads related to inventory system?

if you want to really make it work, it's a good idea to pick up JS and look through API reference. It's really short.

You can also take a look on the example made by me here:https://zeicmann.itch.io/ccb-var.... Or look up forum for other examples made by other people. In particular, I remember Robo has a video regarding inventory implementation in his game.


Create reply:










 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






Copyright© Ambiera e.U. all rights reserved.
Contact | Imprint | Products | Privacy Policy | Terms and Conditions |