Jump to content
Sign in to follow this  
Dead3yez

Head direction (camera/head movement)

Recommended Posts

Is it entirely possible to return an array (x,y,z) of the position from a unit's head (direction he is looking(camera?))?

Secondly, is there a way to control the head movement and make the player unit look in a certain direction?

I know head-movement is probably do-able via input controls, however, it is imperative that some sort of coordinate/vector can be at least obtained. Otherwise I am guessing that I will have to create my own coords via input values from center of head direction. I am aiming to achieve head movement / free look of a unit via script without user input.

Edited by Dead3yez

Share this post


Link to post
Share on other sites

I don't know of any way of controlling head movement without pulling off some kind of AI trick, but you might find screenToWorld useful by converting the center point of the screen to world coordinates and making a vectorDir by deducting the unit's position from the coordinates.

Share this post


Link to post
Share on other sites

Celery, thanks for the tip. However, I'm not sure whether this is what I am looking for, or I'm really struggling to understand how this will work. Could you maybe explain a little more?

A new question/problem: I have been trying inputaction "lookleft" and various other aim/look controls and cannot get my player to perform the action. Can anyone elaborate on this or post a small example script of how this should work? :)

Share this post


Link to post
Share on other sites

you can determine where the unit is looking withweapondirection. If you need to determine what the weapon is, use weapons like this:

player sidechat format ["weapons are %1", weapons player]

and determine where it is pointed with

player sidechat format ["weapon is pointed %1 %2 %3",weapondirection "weapon class" select 0, weapondirection "weapon class" select 1,weapondirection "weapon class" select 2

. You will need the script commands described in the weapondirection entry to convert the numbers to a compass direction. I WISH I could tell you how to determine the degrees up or down the weapon is pointed, but I can't figure that out.

As far as making a unit look a certain way, for AI try dotarget or dowatch but near as I can tell you can't force a player. If it were possible it would solve about 42 problem I am having with a script I am writing/fighting.

Hope this helps

Share this post


Link to post
Share on other sites
Celery, thanks for the tip. However, I'm not sure whether this is what I am looking for, or I'm really struggling to understand how this will work. Could you maybe explain a little more?

You get your head's vectorDir like this:

_pos=screenToWorld [0.5,0.5]

_dir=[(_pos select 0)-(getPos _unit select 0),(_pos select 1)-(getPos _unit select 1),(_pos select 2)-(getPos _unit select 2)]

A new question/problem: I have been trying inputaction "lookleft" and various other aim/look controls and cannot get my player to perform the action. Can anyone elaborate on this or post a small example script of how this should work? :)

inputAction only tells if the keys assigned to that action are currently pressed.

Share this post


Link to post
Share on other sites

@Zombie

I really need to find the head direction as weapondirection does not account for freelook. The script that I want to make is not for AI, just for human units. Although, thanks as you have got me brainstorming a little into other ideas for possible solutions.

@Celery

_pos=screenToWorld [0.5,0.5]

_dir=[(_pos select 0)-(getPos _unit select 0),(_pos select 1)-(getPos _unit select 1),(_pos select 2)-(getPos _unit select 2)]

Technically _pos select 2 does not exist/equal to 0? Does this screw up what values you where expecting?

Anyhow, I seem to be getting some strange values from this, however, they are corresponding with headmovment and direction.

#start
_unit = _this select 0
_pos = screenToWorld [0.5,0.5]
_posx = _pos select 0
_posy = _pos select 1
_posz = _pos select 2
_dir = [(_pos select 0)-(getPos _unit select 0),(_pos select 1)-(getPos _unit select 1),(getPos _unit select 2)]
_dirx = _dir select 0
_diry = _dir select 1
_dirz = _dir select 2

hint format["%1 \n%2 \n%3 \n%4 \n%5 \n%6", _dirx, _diry, _dirz, _posx, _posy, _posz]

~0.02
goto "start"

[edit]

Getting there now. I have studied the values and I think I can get what I want out of this. I will try and stress myself out when I am less tired. :)

[edit]

Greattttttt. I really thought there would of been a command to execute actions like lookleft, aimheadleft etc. Is there anyway to press a virtual key stroke or perform the said actions through a script?

Edited by Dead3yez

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  

×