Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-23-2004, 02:12 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #2  
Old 11-23-2004, 03:05 AM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
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
__________________

Reply With Quote
  #3  
Old 11-23-2004, 03:22 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #4  
Old 11-23-2004, 03:31 AM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
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;

__________________

Reply With Quote
  #5  
Old 11-23-2004, 04:05 AM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
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
__________________

Reply With Quote
  #6  
Old 11-23-2004, 11:14 PM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
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)
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
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 +2. The time now is 11:30 AM.


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