1. ## Always going left..

Ok.. i will try to explain it.

What i want is to move the player 1 meter to his left, no matter what direction he is watching.

Esp if I can do this with vector, velocity would be awesome.

The true purpose is to use the math for a missile guidance system but got problem with the moving to left. (or right).

So anyone that can give me any pointers?

2. Originally Posted by granQ
What i want is to move the player 1 meter to his left, no matter what direction he is watching.
try http://community.bistudio.com/wiki/modelToWorld

3. ah, I think I get what you mean. That way I can find the "left" position of the missile and setpos it.. not as cool as using setvelocity but i guess it works

Will try it later

4. Oki.. i did a script, tried to use your suggestion with "modelToWorld". However i keep getting errors like: generic error #sleep 2;

So could anyone see something wrong with this?

Code:
```/*
Steer missile script made by granQ.
Made for SFP, Swedish Forces Pack.
Feel free to use, adjust for own purposes.
Script can for instance be started with an fired eventhandler.
*/

_vehicle = _this select 0;
_weapon = _this select 1;
_ammo = _this select 4;
sleep 0.1;

_missile = NearestObject [_vehicle, _ammo];

player sidechat format ["Defined: %1 as _missile", _missile];

if ("ARRAY" == typename _missile) then
{
_missile = _missile select 0;
};
if ("OBJECT" == typename _missile) then
{
while {alive _missile} do
{
_dirArray = _vehicle weaponDirection _weapon;
_dirElev = asin(_dirArray select 2 ) - asin( vectorDir vehicle player select 2);

_dirDegrees = (_dirArray select 0) atan2 (_dirArray select 1);
_dirToMissile = ((getpos _missile select 0) - (getpos _vehicle select 0)) atan2 ((getpos _missile select 1) - (getpos _vehicle select 1));
_dirDegrees = _dirDegrees + 360;
_dirToMissile = _dirToMissile + 360;

if (_dirToMissile < _dirDegrees) then
{
_WorldPos= _missile modelToWorld [0.2,0,0];
_missile setpos _WorldPos;
};
if (_dirToMissile > _dirDegrees) then
{
_WorldPos= _missile modelToWorld [-0.2,0,0];
_missile setpos _WorldPos;
};

_height = (getposASL _missile select 2) - (getposASL _vehicle select 2);
_distance = _vehicle distance _missile;
_degreeToMissile = asin (_height/_distance);

if (_dirElev > _degreeToMissile) then
{
_WorldPos= _missile modelToWorld [0,0,0.2];
_missile setpos _WorldPos;
};
if (_dirElev < _degreeToMissile ) then
{
_WorldPos= _missile modelToWorld [0,0,-0.2];
_missile setpos _WorldPos;
};
};
};```

5. Originally Posted by granQ
Oki.. i did a script, tried to use your suggestion with "modelToWorld". However i keep getting errors like: generic error #sleep 2;
From the biki: sleep must be called inside of a context which is interruptible, i.e. a script executed by execVM or spawn.

6. yeah shouldn't be that.. it starts with a fire eventhandler.. and when removed "sleep" i still get error but for something else.

I feel like the game knows its wrong but not what.. which puts me in the same position.

EDIT. Haha, seems you were right actually.. i asked my beta tester what his init was EXACTLY.. he had exec instead of execVM.
Case closed. (somewhat.. the behavior still bad of the missile but..)

7. Just a tip...
_missile = NearestObject [_vehicle, _ammo]; in a parallel scripts will cause you headaches once the mission gets under load. It will fail to catch the missile since it may not be executed while the missile is near enough.

Since the actual eventhandler code is a call, it is better to expand the _this parameter so that the generated object is sent as a 6th (_this select 5) element in the array.

Something like:
Code:
`this addEventHandler ["fired",{_this + [nearestObject [_this select 0,_this select 4]] execVM "scripts\EH-FiredGrad.sqf"}];`

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•