player.ship.spawn spawns objects too close to the ship
Moderators: winston, another_commander, Getafix
player.ship.spawn spawns objects too close to the ship
Hi,
using the trunk version, I regularly have crashes with the released objects when a script uses the spawn method. Could it be that the spawn routine does not include a safe-distance and also ignores the flightpath of the ship, thus sometimes spawning the objects so that they cause instant collisions?
It happens very often with the guardian drones (launched and destroyed in the same moment) and my modified auto-chaff-release.
Screet
using the trunk version, I regularly have crashes with the released objects when a script uses the spawn method. Could it be that the spawn routine does not include a safe-distance and also ignores the flightpath of the ship, thus sometimes spawning the objects so that they cause instant collisions?
It happens very often with the guardian drones (launched and destroyed in the same moment) and my modified auto-chaff-release.
Screet
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: player.ship.spawn spawns objects too close to the ship
It does spawn ships very close by. (Also older oolites) Try spawning a very big ship and you notice you are sometimes partly within. But when standing still while spawning I never had a crash with the object. Just wait until the other ship has moved away before starting to fly again.Screet wrote:I regularly have crashes with the released objects when a script uses the spawn method. Could it be that the spawn routine does not include a safe-distance and also ignores the flightpath of the ship, thus sometimes spawning the objects so that they cause instant collisions?
UPS-Courier & DeepSpacePirates & others at the box and some older versions
it spawns within your ships collision radius, which is calculated in such a fashion using averages of length/width and height of the ship it is spawned at,so it will sometimes spawn in such a manner that you collide with it, or as Erich wrote: Within it.....
its best to spawn other ships when not moving. while smaller objects such as missiles sized objects tend to have a better chance of getting away from the collision area...
This is not a new thing, when I originally wrote the Rock Hermit Locator* for Oolite 1.65, it spawned buoys close to asteroids... but almost never within them...
*Eric Walch wrote the version for Java scripting, taking over development of the RTL with my permission...
Cheers Frame...
its best to spawn other ships when not moving. while smaller objects such as missiles sized objects tend to have a better chance of getting away from the collision area...
This is not a new thing, when I originally wrote the Rock Hermit Locator* for Oolite 1.65, it spawned buoys close to asteroids... but almost never within them...
*Eric Walch wrote the version for Java scripting, taking over development of the RTL with my permission...
Cheers Frame...
Last edited by Frame on Sun May 24, 2009 12:49 pm, edited 1 time in total.
Bounty Scanner
Number 935
Number 935
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
I think spawn was originally mend to be used to add objects in a death action to replace the original. Therefor it is probably deliberate it adds the stuff so close.
The drones should probably not be added with a spawn() but with a addShipsAtPrecisely() and than under the ship so you don't hit it.It happens very often with the guardian drones (launched and destroyed in the same moment) and my modified auto-chaff-release.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
Now there's a good idea. Although I can't use precisely as sometimes we're spawning two of them. But within radius centred around a point below the player ship would work.Eric Walch wrote:The drones should probably not be added with a spawn() but with a addShipsAtPrecisely() and than under the ship so you don't hit it.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
I could use such a code myself for something I'm working onThargoid wrote:Now there's a good idea. Although I can't use precisely as sometimes we're spawning two of them. But within radius centred around a point below the player ship would work.Eric Walch wrote:The drones should probably not be added with a spawn() but with a addShipsAtPrecisely() and than under the ship so you don't hit it.
However, I do wonder if this indicates that Oolite should provide an easy way for this itself, instead of requiring scripts to take this problem into account and handle it themselves. If there are other oxp's which could use a safe spawning, maybe there should be such a method.
Screet
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
The nice thing of spawn() is that it returns the entity (or array of entities) that you can manipulate afterwards. Like Thargoid does with the sledges of the hammerhead.Screet wrote:However, I do wonder if this indicates that Oolite should provide an easy way for this itself, instead of requiring scripts to take this problem into account and handle it themselves. If there are other oxp's which could use a safe spawning, maybe there should be such a method.
An other save method of adding small stuff nearby the ship is using the ejectItem() command. (or ejectSpecificItem() )This adds stuff at a save distance behind the ship. Only drawback of ejectItem is that it always sets scannClass to CLASS_CARGO. This because it uses a function that originally only was mend for ejecting the cargopods.
In case of the guardians you are hitting against, the scann_class is now ROCK. When changing it to CARGO, the player won't see a difference. And to make them unscoopable, define a key inside shipdata of cargo_type = CARGO_NOT_CARGO; Ejecting the guardians is may even look more natural than just spawning.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
My plan is to change the spawning from just a simple player.ship.spawn to
Basically spawning them below the ship, in a 10m sphere centred 20m underneath the ship. So there is enough gap for avoidance I think.
You are right that it may look better to have the ship launch the drones rather than have them just appear below the ship (but as the guardians here are player equipment, who is generally going to see it?). My only concern would be that if the players target is in front of the ship, the drones may try and fly directly through the player ship to reach it. And I think it's more likely that the target is directly in front than directly above.
Plus I guess if there are two guardians spawned (the default number intiially) there is the risk of them hitting one another?
Code: Select all
system.legacy_addShipsWithinRadius("aquatics_guardianPlayer", missionVariables.aquatics_guardianCount, "abs", player.ship.position.subtract(player.ship.orientation.vectorUp().multiply(20)), 10);
You are right that it may look better to have the ship launch the drones rather than have them just appear below the ship (but as the guardians here are player equipment, who is generally going to see it?). My only concern would be that if the players target is in front of the ship, the drones may try and fly directly through the player ship to reach it. And I think it's more likely that the target is directly in front than directly above.
Plus I guess if there are two guardians spawned (the default number intiially) there is the risk of them hitting one another?
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
I just played with the code and the guardians work well. I just replaced in aquatics_equipment.js the line:Thargoid wrote:You are right that it may look better to have the ship launch the drones rather than have them just appear below the ship (but as the guardians here are player equipment, who is generally going to see it?). My only concern would be that if the players target is in front of the ship, the drones may try and fly directly through the player ship to reach it. And I think it's more likely that the target is directly in front than directly above.
Code: Select all
player.ship.spawn("aquatics_guardianPlayer", missionVariables.aquatics_guardianCount);
Code: Select all
for(var i=0; i < missionVariables.aquatics_guardianCount; i++) player.ship.ejectItem("aquatics_guardianPlayer")
UPS-Courier & DeepSpacePirates & others at the box and some older versions