Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, AndrewAMD, NewbieZorro), 16,055 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Keeping the player centered in corridors #342409
09/27/10 14:30
09/27/10 14:30
Joined: Sep 2010
Posts: 42
NS, Canada
gSet Offline OP
Newbie
gSet  Offline OP
Newbie

Joined: Sep 2010
Posts: 42
NS, Canada
So this bit of code has been giving me some trouble, even though it should be pretty straightforward. I'm trying to see how much room the player has on their left, and how much they have on their right, then move them toward the center of the corridor they're in when the two distances are too different.

Usually this works fine, but for some reason when I'm facing a wall and step toward it in some cases it just launches me either left or right. A panel shows my roomleft and roomright vars, and in the cases that it does this stepping toward the wall causes a drastic change even though the amount of room on my left and right hasn't changed in the slightest.

Could be a simple matter of using c_trace wrong, any insight would be greatly appreciated - I've been trying to work this out for 3 days now.

c_trace(my.x,vec_rotate(vector(0,5000,0),my.pan),IGNORE_ME | USE_BOX);
roomleft = vec_dist(my.x,hit.x);
c_trace(my.x,vec_rotate(vector(0,-5000,0),my.pan),IGNORE_ME | USE_BOX);
roomright = vec_dist(my.x,hit.x);
if (abs(roomleft - roomright) > 20 && roomleft < 400 && roomright < 400) c_move(me, vector(0,(roomleft-roomright)*time_step/8,0), NULL, USE_AABB);


"If it's true what you say to me, that the whole world will mourn his death - If the whole world will weep, I will give him back his breath."
Re: Keeping the player centered in corridors [Re: gSet] #342413
09/27/10 14:58
09/27/10 14:58
Joined: Sep 2010
Posts: 42
NS, Canada
gSet Offline OP
Newbie
gSet  Offline OP
Newbie

Joined: Sep 2010
Posts: 42
NS, Canada
Funny how after near endless searching I post, then almost instantly find a solution. Here it is:

http://www.opserver.de/ubb7/ubbthreads.p...true#Post328564

I just replaced my stuff with this, followed by my original c_move:

vec_set(temp_vec, vector(my.x-(trace_dist*cos(my.pan-90)), my.y-(trace_dist*sin(my.pan-90)), my.z+my.min_z+1) );
c_trace(vector(my.x,my.y,my.z + my.min_z+1),temp_vec, IGNORE_ME | IGNORE_PASSABLE); //TRACE LEFT
roomleft = vec_dist(my.x,hit.x);

vec_set(temp_vec, vector(my.x-(trace_dist*cos(my.pan+90)), my.y-(trace_dist*sin(my.pan+90)), my.z+my.min_z+1) );
c_trace(vector(my.x,my.y,my.z + my.min_z+1),temp_vec, IGNORE_ME | IGNORE_PASSABLE); //TRACE RIGHT
roomright = vec_dist(my.x,hit.x);

Hope this helps someone with a similar problem!

Last edited by gSet; 09/27/10 14:59.

"If it's true what you say to me, that the whole world will mourn his death - If the whole world will weep, I will give him back his breath."

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1