Jump to content
Sign in to follow this  
SouthSaturnDelta

setdir (getdir player)

Recommended Posts

Hello gents.

     Have a problem with the setdir command lately.

I set the direction of units to face the direction the player does (dir1),and on its first application all is well.

However,when a second and third use of the same command line is applied,the units will face the direction of the initial command (dir1) regardless of which direction the player is (at that moment) facing.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_dir1 = (getdir player)

_unit1 setDir _dir1

; this inital command works fine.

//

;player now faces in a new dir.

_dir2 = (getdir player)

_unit1 setDir _dir2

;this secondary command alligns unit1 to face _dir1.

//

;player now faces in a new dir.

_dir3 = (getdir player)

_unit1 setDir _dir3

;this tertiary command alligns unit1 to face _dir1.

How might I enable the direction the player is facing to be set for other units more than once?

Many thanks,

SSD

Share this post


Link to post
Share on other sites

2 things: guessing that this is just a extracted bit of your script you've removed any wait/sleep or something else? Because this script as posted will be run through in 0.0whatever seconds and therefor impossible to assign different headings.

Second thing: i guess it is .sqs script. Are the // for a special purpose there? i don't know how a sqs script reacts on them.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_dir1 = (getdir player)

_unit1 setDir _dir1

; this inital command works fine.

~10

;player now faces in a new dir.

_dir2 = (getdir player)

_unit1 setDir _dir2

;this secondary command alligns unit1 to face _dir1.

~10

;player now faces in a new dir.

_dir3 = (getdir player)

_unit1 setDir _dir3

;this tertiary command alligns unit1 to face _dir1.

Try this snippet and tell me what happens.

Myke out

Share this post


Link to post
Share on other sites

You might have more luck with the doWatch command?

Only the problem is, once you issue it, you have to handle it for the entire mission. Also don't try and watch positions to close to the unit in question. Otherwise odd things may happen.

Share this post


Link to post
Share on other sites

Thanks for the feedback lads,greatly appreciated.

These // are just to replace a lot of other stuff going on in the script.Count them as time based in place of ~10 ect, and also setting a new heading as well.

The problem is that I can only assign units/objects to face the players direction once.After this initial use, all consecutive uses of 'SetDir' result in this initial direction.

Example is that I drop bombs from a plane.

They travel with a velocity in the direction of the plane and land,exploding.

Next run though,the bombs are released and travel in this same direction as on the first run,often backwards or to the side irrespective to the planes heading at that instant (I.E. _dir2).

Drives me crazy as in each instance,the would be current direction of the plane is defined for each bombing run.

This applies to scripted bombings,and custom bombs spawned from planes.

I'll try this dowatch,though I assume it applies to units and not objects.

In a nutshell~

_dir1 = _dir2 = _dir3,ect,ect

Must be some way around it?

Cheers,

SSD

Share this post


Link to post
Share on other sites

That code is correct so the problem must be elsewhere in the script. There is no reason that shouldnt work. It only depends when your getting the players dir and how you are obtaining that event wether with a trigger or EH or whatever.

For a plane I would test out flying in a direction starting one way and flying opposite dir with hints to tell you what your dir value is with your script running. Set two triggers to fire a script that just tells you the dir values. Fly through them two different directions.

I usually put exit right after a problem area in a script like this just as a quick cutoff untill fixed.

If the dir variables are what they should be then try to run your code further on and check for errors. Im suspecting the dir variables are not being set when you think they are. Then you might see the exact same value as your claiming or you will see two dif values as you should or whatnot.

If youre flying and getdir player while flying and then setdir something with the data right after, it will work as expected.

Must look funny watching those bombs as is smile_o.gif

If the dir variables are all in the same script it should be ok to just update the same variable.

dir1 = getdir player

declare condition

do stuff

@condition

dir1 = getdir player

Do hints at these get dir points so you can get transparency into what the script is doing and you should be able to trace back from there.

Also if they are in one script only they could be local variables as well.

_dir1 = getdir player

Share this post


Link to post
Share on other sites

Hi,

  I think the problem lies in the velocity I assign the bombs after they are dropped.

I need to sort out their headings as below shows ...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_bomb setVelocity [(velocity AIR1 select 0)+70,(velocity AIR1 select 1),(velocity AIR1 select 2)*1.2]

Its this <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(velocity AIR1 select 0)+70 part thats the culpret here, and not setdir as I assumed.

I need for these bombs to fall in the direction of the bomber plane with a forward velocity.

Using

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(velocity AIR1 select 0)*1.2    ,or whatever appears to have no effect on the forward speed of the bombs - and it looks a bit naff when a high speed plane drops low speed ordnance....

I'll try working with scalers instead of these vectors and seee if anything can be done to improve things.

SSD

Share this post


Link to post
Share on other sites
Quote[/b] ]I'll try this dowatch,though I assume it applies to units and not objects.

Yeah, it's no good for a vehicles driver\pilot.

Quote[/b] ]appears to have no effect on the forward speed of the bombs

You have to apply the multiplier in a loop. Otherwise it's like you said. You won't see any result.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">WaitUntil

       {

       _bomb setVelocity [(velocity _bomb select 0)*1.2,(velocity _bomb select 1)*1.2,(velocity _bomb select 2)*1.2];

       (IsNull _bomb)

       };

Just adjust the value 1.2 for each vector until you get the desired result.

If you want to get the bomb to travel at a fixed speed or the bomb is created with CreateVehicle then you will have to use trigonometry.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×