2 registered members (AndrewAMD, Ayumi),
838
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
free-fall movement
#285158
08/17/09 12:47
08/17/09 12:47
|
Joined: Mar 2009
Posts: 276 Cebu City, Philippines
boyax
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
|
I'm having problem moving my player entity in free-fall... In such case also I need to adjust the player tilt= -40 instead of moving with it directly straight to its z-axis it moves back.. some illustration: The correct movement is the dashed line and not to move down backwards (straight line).. the code i've used is just:
c_move(player, vector(0,0,myVerticalAccel), nullvector, IGNORE_PASSABLE | GLIDE);
player.tilt = -40;
player.tilt = clamp( player.tilt, -90,90 );
any way idea how I could solve it? Thanks
|
|
|
Re: free-fall movement
[Re: boyax]
#285159
08/17/09 12:55
08/17/09 12:55
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
Expert
|
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
c_move(pointer, vector_in_own_coord_system, vector_in_world_coord_system, flags);
you used the own coords/angles to move, instead of the world angles. So he moves the way he is looking at. ^^
vector(0,0,myVerticalAccel), nullvector,
just change them to:
nullvector, vector(0,0,myVerticalAccel),
Last edited by Espér; 08/17/09 12:56.
|
|
|
Re: free-fall movement
[Re: boyax]
#285160
08/17/09 12:56
08/17/09 12:56
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
Maybe, I understand your problem wrong, but here is my soltion: Exchange 'nullvector' with 'vector(0,0,myVerticalAccel)', because the first vector is relative to the entity's angles and the second is absolut, means relative to the worlds angles. c_move(player, nullvector, vector(0,0,myVerticalAccel), IGNORE_PASSABLE | GLIDE); From the manual: c_move(ENTITY* entity,VECTOR* reldist,VECTOR* absdist,var mode) Moves an entity over a certain distance while performing collision detection, triggering collision events, and gliding along obstacles.
The first vector reldist gives a relative distance and direction in rotated entity coordinates, i.e. the direction that the entity is facing. The second vector absdist gives an absolute distance and direction in world coordinates. http://www.conitec.net/beta/ac_move.htm
|
|
|
Re: free-fall movement
[Re: boyax]
#285787
08/20/09 07:00
08/20/09 07:00
|
Joined: Mar 2009
Posts: 276 Cebu City, Philippines
boyax
OP
Member
|
OP
Member
Joined: Mar 2009
Posts: 276
Cebu City, Philippines
|
I still have problem with this... My movement is govern that the everytime I press cursor up (key_cuu) it will move up (feels like flying), then, the mouse_force.x would change the pan/roll of the player.... but my problem now is that, when the player is on the ground and moves the mouse (left/right), the player moves back.. I don't know why? I think there should be an external force that go against the movement when in the ground. Here's the player's action code:
action act_player()
{
var myVerticalAccel = 0.0005;
var dist_down = 0;
player = my;
vec_for_min(vFeet,player); // vFeet.z = distance from player origin to lowest vertex
while(1)
{
if( player.z > 30000) //height limit
{
player.z = 30000;
myVerticalAccel = 0;
}
newValue = 0;
if(mouse_left || key_cuu)
{
//temp += 0.01;
newValue += 40;
}
else if(key_cud)
{
//temp -= 0.01;
}
if (c_trace(player.x,vector(player.x,player.y,player.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX) > 0)
{
dist_down = player.z + vFeet.z - target.z; // get distance between player's feet and the ground
}
else
{
dist_down = 0;
}
if(dist_down <= 0)
{
myVerticalAccel = 3;
}
myVerticalAccel -= 0.4;
SpeedBuffer(); //calculate constant speed, just put it on buffer
speed = totalSpeed/30;
if(speed < 2)
{
speed = 0;
}
AverageSpeedBuffer();
AverageSpeed = totalSpeedAverageSpeed/50;
///
speedDifference = speed - AverageSpeed;
myVerticalAccel += speedDifference/15;
c_move(player, vector(speed,0,myVerticalAccel), nullvector, IGNORE_PASSABLE | GLIDE);
player.tilt = speedDifference*2;
player.tilt = clamp( player.tilt, -90,90 );
player.roll = clamp( (player.roll + mouse_force.x * time_step * 15), -50, 50 );
player.pan = (player.pan-player.roll*time_step*0.05);
isometric_camera();
totalSpeed = 0;
totalSpeedAverageSpeed = 0;
wait(1);
}
}
|
|
|
|