Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   attachplayertoobj vehicles (https://forums.graalonline.com/forums/showthread.php?t=56126)

ApothiX 11-23-2004 02:12 AM

attachplayertoobj vehicles
 
Hello everyone,

Just recently I decided to attempt to fabricate a vehicle that more than one player may enter, and ride around in. I have gotten the ganis to correctly show, and the setshape2s to work, but the one thing I am having problems with is the adjusting of the player's x and y when the vehicle turns.

My question to you is, is there a general equation for updating the player's x and y based on the direction of the vehicle? If so, would you mind helping me to figure out what that equation is?


All help is much appreciated.

ZeroTrack 11-23-2004 03:05 AM

it depends on the width of the car as well. what excatly happens when you make a turn? where do both players end up? excatly what is your current equation. I have already made a multi person vehicle on bravo so i'd be more than glad to help if i knew more about your current script

ApothiX 11-23-2004 03:22 AM

My car is 8 tiles by 11 tiles at direction 0, and the equation I tried was:

PHP Code:

dx = (x+(8+vecx(prevdir)*3)/2) - playerx;
dy = (y+(8+vecy(prevdir)*3)/2) - playery;
playerx = (x+(8+vecx(dir)*3)/2) + dy vecy(dir)*3;
playery = (y+(8+vecy(dir)*3)/2) + dx vecx(dir)*3

It works for directions 0 and 1, (which is probably just a coincidence) but the rest it throws the player off to some other position, sometimes not even in the car

ZeroTrack 11-23-2004 03:31 AM

Quote:

Originally Posted by ApothiX
My car is 8 tiles by 11 tiles at direction 0, and the equation I tried was:

PHP Code:

dx = (x+(8+vecx(prevdir)*3)/2) - playerx;
dy = (y+(8+vecy(prevdir)*3)/2) - playery;
playerx = (x+(8+vecx(dir)*3)/2) + dy vecy(dir)*3;
playery = (y+(8+vecy(dir)*3)/2) + dx vecx(dir)*3

It works for directions 0 and 1, (which is probably just a coincidence) but the rest it throws the player off to some other position, sometimes not even in the car

have you tried debuging so it returns the player postions to say something like the rc? perhaps
PHP Code:

f(created||timeout) {
 
dx = (x+(8+vecx(prevdir)*3)/2) - playerx
 
dy = (y+(8+vecy(prevdir)*3)/2) - playery
 
testx = (x+(8+vecx(dir)*3)/2) + dy vecy(dir)*3;
 
testy = (y+(8+vecy(dir)*3)/2) + dx vecx(dir)*3;
 
sendtonc Debug#v(testx) #x(testy);
 
timeout=1;



ZeroTrack 11-23-2004 04:05 AM

as far an a standered equation .... it does exisit esp considering everyone has diffrent img sizes , its not like getting the x and y of directly in front of a player which pretty much everyone uses the same one cause player size doesnt change , unless your using kingdom bodies, but never the less if its a new equation you have to just figure out an equation that will support what your tring to do, which can be done by a vast knowledge of math or trial and error process

Dach 11-23-2004 11:14 PM

matrix of revolution

old_dx = vehicle_midx - middle_playerx
old_dy = vehilcle_midy - middle_playery
sin = sin(change_in_angle_of_car)
cos = cos(change_in_angle_of_car)
new_dx = old_dx*cos-old_dy*sin
new_dy = old_dy*cos+old_dx*sin


array = {-1,0, 1,0, -1,-1, 1,-1} holding the values of player position for each seat in car when car direction = 3 (theta = 0)
sin = sin(angle_of_car)
cos = cos(angle_of_car)
new_dx = array[player_pos_in_car*2]*cos-array[player_pos_in_car*2+1]*sin
new_dy = array[player_pos_in_car*2+1]*cos+array[player_pos_in_car*2]*sin

non-matrix of revolution

array = {1,pi/4, 1,3*pi/4} array of playerpos in car using polar coordinates
new_dx = array[player_pos_in_car*2]*cos(array[player_pos_in_car*2+1]+angle_of_car)
new_dy = array[player_pos_in_car*2]*sin(array[player_pos_in_car*2+1]+angle_of_car)


All times are GMT +2. The time now is 02:14 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.