Code help! How to calc a position...
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
Code help! How to calc a position...
Hi mates,
I need to move a ship to a target ... but needs to go to a position just for example, 3km, before it. So, this position must to be between me and the target, in a direct direction.
The unique possible code command that i found is create_position_outside_boundingbox but this one have three problems: the first one is that you cant set any position before bounding box, the second is that boudingbox varies a lot in size, third, by these 2 first issues, on big stations boundingbox can be really that far from station body itself.
Any idea? Any code that can do it - knowing the start position and the target position?
Thanks by any help!
I need to move a ship to a target ... but needs to go to a position just for example, 3km, before it. So, this position must to be between me and the target, in a direct direction.
The unique possible code command that i found is create_position_outside_boundingbox but this one have three problems: the first one is that you cant set any position before bounding box, the second is that boudingbox varies a lot in size, third, by these 2 first issues, on big stations boundingbox can be really that far from station body itself.
Any idea? Any code that can do it - knowing the start position and the target position?
Thanks by any help!
-
- Posts: 2963
- Joined: Tue, 18. Nov 14, 16:23
I'm a bit rusty, but
?
I'd change "exact" to a "min" and/or "max" though in case it couldn't find a safepos at exactly 3km, unless you're sure it'll be unobstructed.
that should place it at 3km from $target in the direction of player.primaryship
Code: Select all
<get_safe_pos result="$Rubini_MovePos" directionobject="player.primaryship" zone="this.zone" radius="this.ship.size / 2.0" object="$target" exact="3km"/>
<move_to object="this.ship" destination="this.zone">
<position value="$Rubini_MovePos"/>
</move_to>
I'd change "exact" to a "min" and/or "max" though in case it couldn't find a safepos at exactly 3km, unless you're sure it'll be unobstructed.
that should place it at 3km from $target in the direction of player.primaryship
-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
Thanks w.evans! I will try it now and post here my finds.w.evans wrote:I'm a bit rusty, but?Code: Select all
<get_safe_pos result="$Rubini_MovePos" directionobject="player.primaryship" zone="this.zone" radius="this.ship.size / 2.0" object="$target" exact="3km"/> <move_to object="this.ship" destination="this.zone"> <position value="$Rubini_MovePos"/> </move_to>
I'd change "exact" to a "min" and/or "max" though in case it couldn't find a safepos at exactly 3km, unless you're sure it'll be unobstructed.
that should place it at 3km from $target in the direction of player.primaryship
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
could you make a sketch describing what you want, including all factors which should have an influence on it? i think it should be relatively easy.
Commands of use here:
<transform_position/> - to get a Position in the coordinate system of an object (eg in front of something) or apply a rotation to a poition (which can be relative to anoter position)
<create_orientatin/> - to get a rotation value for something to look at/away from another object/position
Commands of use here:
<transform_position/> - to get a Position in the coordinate system of an object (eg in front of something) or apply a rotation to a poition (which can be relative to anoter position)
<create_orientatin/> - to get a rotation value for something to look at/away from another object/position
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help

-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
@UniTrader,
Is something that simple: take a position in front of a target (from a given startposition direction - the short one). If it is object coordenates, then convert to zone coordenates. The ship which will move to, then, rotate direct to this position and goes to that position. Seems easy, but we have not a easy command to calc that position. See my reply below for w.evans.
@w.evans,
It dont work as intend. The get_safe_position as above continues to be in a random pos in a bubble around the target, or at least isnt the short one.
Is something that simple: take a position in front of a target (from a given startposition direction - the short one). If it is object coordenates, then convert to zone coordenates. The ship which will move to, then, rotate direct to this position and goes to that position. Seems easy, but we have not a easy command to calc that position. See my reply below for w.evans.
@w.evans,
It dont work as intend. The get_safe_position as above continues to be in a random pos in a bubble around the target, or at least isnt the short one.
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
so you basically want to get a Zone position in front of a Ship to move to? easy..
on what scale do you want to use this? just single cases or for basically everyone?
Code: Select all
<transform_position name="$Position" refposition="$ship.position" refrotation="$ship.rotation">
<position x="0" y="0" z="$ship.size * 1.5" />
</transform_position>
on what scale do you want to use this? just single cases or for basically everyone?
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help

-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
Thanks again Uni to look at this.UniTrader wrote:so you basically want to get a Zone position in front of a Ship to move to? easy..Code: Select all
<transform_position name="$Position" refposition="$ship.position" refrotation="$ship.rotation"> <position x="0" y="0" z="$ship.size * 1.5" /> </transform_position>
on what scale do you want to use this? just single cases or for basically everyone?
Just for some single cases. Its just to approach a boarder ship to an enemy target ship/station, in a more direct and short path possible. Must do it without collide with the target itself. This is why i need to have a safepos (what is easy using get_safe_pos) but needs to be directly in front of the target from ship boarder reference, in a safe distance.
-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
Humm. Let me try to explain better and why. I just need the short path from a startposition (attacker) to its target - but 3km (can be any valour) before the target. Your suggestion above will always aim the front of the target (sorry, i have not explained well) and isnt this what i need. Must be from any direction: side, up, dow, behind, front, etc...but needs to be always the short path to the target.
I guess that the best explain is "the short path between two points in a 3d world". First coordinates is the startpoint (the attacker) the second coordinates is 3km(can be any valour) before target one. The direction and rotation dont matters.
I guess that the best explain is "the short path between two points in a 3d world". First coordinates is the startpoint (the attacker) the second coordinates is 3km(can be any valour) before target one. The direction and rotation dont matters.
Last edited by Rubini on Sun, 3. Apr 16, 04:31, edited 1 time in total.
-
- Moderator (Script&Mod)
- Posts: 14571
- Joined: Sun, 20. Nov 05, 22:45
ok, my question was more in relation to the flight control model.. most big ships use the Spline FCM which works with pre-calculated paths, but for some purposes which need a more direct control (your post seemed like it) the Steering FCM may be more useful (this FCM basically works like the classic X's Autopilot which heads to the destination in a straight line and avoiding obstacles when encountering them), but a bit more refined since it doesnt avoid the full sphere of the object size but checks actual geometry in flight direction - this is more ressource-intensive than Spline FCM on-rails-mechanics though)
if not stated otherwise everything i post is licensed under WTFPL
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter
I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help
Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help

-
- Posts: 452
- Joined: Mon, 7. May 07, 05:17
Yes, and that "create_position_outside_boundingbox" do exactly this, what i want. But have the downside to always use positions outside boundingbox, which is in certain cases (big objects like big stations) too much wide.UniTrader wrote:ok, my question was more in relation to the flight control model.. most big ships use the Spline FCM which works with pre-calculated paths, but for some purposes which need a more direct control (your post seemed like it) the Steering FCM may be more useful (this FCM basically works like the classic X's Autopilot which heads to the destination in a straight line and avoiding obstacles when encountering them), but a bit more refined since it doesnt avoid the full sphere of the object size but checks actual geometry in flight direction - this is more ressource-intensive than Spline FCM on-rails-mechanics though)