Issue with setting up a simple Mining Ship[RESOLVED]

Greetings

I hope all is well

Just to get this out the way. I have been using Gdevelop for maybe a 3 months on and off, messing around with it, its Events system which I really like and find easy (though limiting) then learning to write code

Anyway reason I have been on and off, is basically when I hit a road block and then come back to try to tackle the issue but this issue I am having has got me pulling my hair out

I am trying to create a simple space game, just to see if I can do it and I know many people say start with something simple lol. It would be like open world with RPG elements in 2D however I am having issue with the mining ship I am trying create with just basic commands, to go to Asteriod A, shot laser then go to next Asteriod and repeat.

If I have more than one mining ship on the field then they would just sit there. How or is it possible for more and tell the game engine that there are two different ships, cos they are acting or following their task from what I understand but somehow the engine reading only one Mining ship instead of two so that both have different tasks to do even though its the same… I am not sure if that makes

MiningShip

Okay i think this mght be a lil more complicated then i thought but I assume I would need to create something like inventory system for each instance of the mining ship, something like a varible to store or keep track of each instance then check for its cargo hold and see whether its full, if full then move on to the station and empty out otherwise keep mining until full

Unless there is another way of doing this?

Can you post a pic or 2 of the events you’re using to move the ships? I agree, the ship would need a variable for their storage level/capacity and maybe a variable to tell it what mode it’s in. It could use the storage level but extra logic states usually helps to make the events more understandable.

Without knowing how you’re moving the ships or choosing the asteroids. It would just be guessing.

Sure this the External Event I am using to control the mining and selecting the rocks, also I have added varible for Mining Cargo and setting a scene varible (MiningOp) to check if the cargo is full or empty, if empty the mining op does not activate and the ship will return to the station if there are no rocks on the field

and I messed around with Ray casting to make sure the miningscop or laser is pointed at the rock before creating the laser beam

As request though, above is the movement events for the mining ship(s)

Okay I will then need to figure that out as I have the mode as you mention, just need to figure a way to link it in such manner that it accounts for more than one ship and doesnt treat every ship on the field as one as I have problem now where if the ships cargo is full, both ships would head to the space station

Thanks for the response though @Keith_1357

Interesting… I just tested it again and its seems like it works sometimes but not all the time - seems to only work when i intervene. It’s as though getting stuck on a rock either too far perhaps from them for the mining scoop to reach so they just sit there… so I can’t seem to figure out why they pausing

The pathfinder prevents collision. If the asteroids are obstacles then they won’t always trigger a collision event.

The pathfinder behavior has a condition like reached destination. You can use that to switch to a mining state. And then use pick nearest asteroid.

Once the asteroid is mined switch back to seek out the next one. If it’s tank is full set it to return home to empty itself.

Some people use an incrementing mode. I prefer states. It’s a little more work but for me it’s easier to understand words instead of numbers.

I don’t have the time right now to go into any further detail. I’m sure someone else can chime in. Otherwise, I can check in later.

@Keith_1357 Thanks. I will give that a try it later and give an update here how it goes

Much Appreciated!

I looked at your events again. I don’t think it was the pathfinder but the laser. I really don’t understand what the scoop or laser is. It’s just not clear to me. It’s a very interesting project but also difficult sometimes when you only see parts of a project. You start making assumptions that just makes things worse.

I’m not seeing the issue maybe someone else can. In the meantime, it looks interesting so I’m throwing together a rough mockup of how I would do it. Maybe it will be more help than I am currently.

Alright. This was fun. I didn’t fully test my logic. I didn’t add any checks for if there are no more asteroids and since I have the ships lock onto an asteroid then nearby ships might avoid their nearest asteroid.

I’m open to any questions. It’s more than you asked for but this was fun and based on your concept.

project files:
doug13579/gdevelop-space-miner-example (github.com)

1 Like

Thanks @Keith_1357 , I understand. Well its just that scoop to mine the rocks, I meant to call it laser but I guess I wanted to be different there lol

I figured how to create shipIDs. I just need to figure the logic as you say, to attached or assign each one now a cargo bay. Whoop whoop

As it stands now, they sharing the same cargo bay varible, unless I make that a scene varible and somehow set to the ship
ShipID

1 Like

Ok, I see now. I thought the scoop was the base or something. My version adds the ore to the ship. BTW. I love the graphics and concept.

Edit: I’m out of here for now. My only addition is trigger once events inside loops like for…each have a tendency to behave erratically.

@Keith_1357 Wow that was awesome and so quick. I have been doing this for a 3 months… Well a month on and off and you threw that togehter so quick

That seems so much more simplier and probably is as that is what I was trying to go for to simulate mining or at least breathing universe in my game.

Question: How are you getting the ship to moving so smoothly. I find with the pathfinder behavor its seems to grid like or “unatural” considering its supposed to be in space or is it because your ships are so tiny compared to what I am using

If they moving so quickly. I was working on drone like function for mining frigates apart from the laser as I keep getting side tracked trying stuff or adding stuff without completing other features

If you see my GIF above, I think you can see what I am talking about it the gird like movement

Again great work on the mini game, you could have that setup like NPC with the player trying to compete with who gets the most rocks mined or even make multiplayer option

I used the default pathfinder settings. I also only triggered the move once. IDK if that matters. I think your version is also moving over shorter distances. Mine was designed differently and some of the wiggle gets spread out. I think.

I will take a look a the settings there and see if those can be tweaked @Keith_1357 , thanks

Okay I cant see to figure this out, if anyone is able to help

I am trying to basically assigned a cargo bay to each instance of the mining ship however the issue I am having is the game assigns an ID to each instance however each instance of the mining ship is sharing the same cargobay varible.

How would I go about then assign there own cargo bay using varible, please

You can use matching ids or use linking. Linking is so helpful. It’s under [other] conditions and actions. You can link ships and bays but not bays to bays. I used linking in my example to link the asteroids and emitters to their ship.

For id variables it’s:

For each ship
— value of id cargoBay equals value id of ship
(Now, both instances of each object are picked)

Or vice versa depending on what you’re doing and you might need another for each for multiple groups

For each cargoShip
--- ship id equals cargo Id
------- for each ship

Or with linking.

Link ship(s) to cargo vessel(s)

For each ship
… Among cargo linked to ship

Or

For each cargo
— among ships linked to cargo

If the cargo ships had multiple cargo bays or vice versa you might need to loop through each group.

Depending on the events you might need to use pick all objects from time to time as the conditions basically filter objects out. Sometimes you need to reset the available instance list. You might also need to repeat previous conditions like collision to repick the appropriate objects.

Also, with linking, order matters when checking for links. It only picks one side of the linked group at a time. You either find the children linked to a parent or parents linked to a child. Subtle but important. one might add 5 children while the other way it only adds the parents not any other linked children.

1 Like

Hey @Keith_1357

I hope you well

I just wanted you know, thank you. I couldn’t use or figure out the Var method of linking said ship and its cargo bay however using your 2nd suggestion linking object resolved my issue with said ship cargo bay updating like it should instead. Thank you so much now I can refine the code and move

1 Like

You’re welcome. I’m glad I could help.

1 Like