Raised This Month: $51 Target: $400
 12% 

Detecting other player's movement direction


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StaticDude
Junior Member
Join Date: Dec 2013
Old 12-31-2013 , 12:36   Detecting other player's movement direction
Reply With Quote #1

Hi. I want to detect in which direction player is moving from other player's point of view. Here's the pic:

[IMG]http://img854.**************/img854/1794/qaqy.png[/IMG]

So I need to detect if player2 is moving right/left from player1 point of view. Thanks.
StaticDude is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 12-31-2013 , 15:34   Re: Detecting other player's movement direction
Reply With Quote #2

Check which buttons they're pressing?
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
StaticDude
Junior Member
Join Date: Dec 2013
Old 12-31-2013 , 16:46   Re: Detecting other player's movement direction
Reply With Quote #3

Quote:
Originally Posted by Backstabnoob View Post
Check which buttons they're pressing?
I don't think this is good idea, because I need to take in account other player's point of view. For example: I'm looking at other player which moves right for me but left for him and etc.
StaticDude is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 12-31-2013 , 19:38   Re: Detecting other player's movement direction
Reply With Quote #4

Just left/right/forward/backwards that cuts off at a 45 degree angle? Or only left/right? If so, what angle should it be concidered as moving forward/backwards?

I'm not saying I can do it because, at least for me, it's quite complicated math. I just want to clear it out before even starting on it.
__________________
Black Rose is offline
StaticDude
Junior Member
Join Date: Dec 2013
Old 01-01-2014 , 06:51   Re: Detecting other player's movement direction
Reply With Quote #5

Yeah, detecting other directions is also needed. I'll try to explain it better: I need to detect in which way player moves on my screen (left/right/up/down/left&up/left&down and etc).

Picture

Last edited by StaticDude; 01-01-2014 at 06:53.
StaticDude is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-01-2014 , 07:14   Re: Detecting other player's movement direction
Reply With Quote #6

Could be usefull to tell what you gonna do with it.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
StaticDude
Junior Member
Join Date: Dec 2013
Old 01-01-2014 , 07:52   Re: Detecting other player's movement direction
Reply With Quote #7

I'm gonna change order of some checks depending on player movement direction.
StaticDude is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 01-01-2014 , 14:51   Re: Detecting other player's movement direction
Reply With Quote #8

Quote:
Originally Posted by StaticDude View Post
Yeah, detecting other directions is also needed. I'll try to explain it better: I need to detect in which way player moves on my screen (left/right/up/down/left&up/left&down and etc).
I don't have time to make code for you but what I would do would be:

1 - Create a plane based on the position of your eyes and your view angle.
2 - Push the enemy current origin and previous origin to your plane, that will give you two vectors on your plane.
3 - Subtract them (current-previous) and you will have a vector that points the previous from the current relative to your plane.
4 - Now what you want is the angle of that vector in your plane.

With include xs help:

1 -
Code:
// Construct a plane out of 3 points
    // tested
    XS_LIBFUNC_ATTRIB xs_plane_3p(Float:plane[], const Float:p1[], const Float:p2[], const Float:p3[])
This function constructs a plane with three points.
The three points you can get them from:

Code:
XS_LIBFUNC_ATTRIB xs_anglevectors(const Float:angles[3], Float:fwd[3], Float:right[3], Float:up[3])
Pass to that function your viewangles, get your fwd,right an up, and add to those three vector the origin of your eyes. Then create a plane with those three vectors.

2 -
Code:
XS_LIBFUNC_ATTRIB xs_projpoint_onplane(const Float:plane[], const Float:point[], Float:out[])
3 -
Code:
XS_LIBFUNC_ATTRIB xs_vec_sub(const Float:in1[], const Float:in2[], Float:out[])
4 - My solution to this part is a bit trickier.
As the last vector you got is relative to your plane, you can define it over the fwd and right vectors you got from xs_anglevectors (before adding eyes origin to them) like

α * fwd + β * right = vector
α *(a,b,c) + β*(d,e,f) = (x,y,z)

This gives you three equations (remember you are just missing α and β):

aα + βd = x
bα + βe = y
cα + βf = z

You solve them and you got α and β.
Now, you have the 2D vector (α,β) that is what you want. Remember that you can then also calculate the angle of this 2D vector with normal trigonometric functions.
__________________

Last edited by joaquimandrade; 01-01-2014 at 14:55.
joaquimandrade is offline
StaticDude
Junior Member
Join Date: Dec 2013
Old 01-01-2014 , 15:54   Re: Detecting other player's movement direction
Reply With Quote #9

I've always had problems with such type of math, but I'll try it out. Thanks.
StaticDude is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 01-01-2014 , 16:37   Re: Detecting other player's movement direction
Reply With Quote #10

@joaquimandrade:

Does your method take into account simply holding forward and right at the same time without actually looking the way you're moving? Because the view angle shouldn't really matter in this case, rather than the real direction the player has moved at, which would probably be best checked in a think function with some origin substraction.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 01-01-2014 at 16:37.
Backstabnoob is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode