Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 838 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Collision #361959
03/05/11 22:42
03/05/11 22:42
Joined: Sep 2006
Posts: 292
M
Mythran Offline OP
Member
Mythran  Offline OP
Member
M

Joined: Sep 2006
Posts: 292
How can i make the player react to models the same way
it reacts to blocks?

Thanks

Re: Collision [Re: Mythran] #361961
03/05/11 22:55
03/05/11 22:55
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Set POLYGON flag on static models and use USE_POLYGON in your c_move instruction.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Collision [Re: 3run] #361964
03/05/11 23:08
03/05/11 23:08
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
If you use the USE_POLYGON flag in your c_move instruction, the entity will perform polygon-based collision detection with everything. To only have this behavior with a single object, use the POLYGON flag on the static models as 3run suggested.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Collision [Re: Redeemer] #361966
03/05/11 23:18
03/05/11 23:18
Joined: Sep 2006
Posts: 292
M
Mythran Offline OP
Member
Mythran  Offline OP
Member
M

Joined: Sep 2006
Posts: 292
So how can i add c_move in here?

Thanks



action my_player
{
var walk_percentage; // controls the "walk" animation speed
var stand_percentage; // controls the "stand" animation speed
var climb_percentage; // controls the "climb" animation speed
var movement_speed; // player's movement speed
player = my; // I'm the player
//my.narrow = on;
c_setminmax(my);
my.ambient = -50; // play with the ambient value (-100...100)
my.transparent = on; // the player could be transparent
my.alpha = 100; // but will be opaque if the camera doesn't run into obstacles
my.skill41 = my.camera_height; // store the height of the camera in relation to player's origin
my.skill42 = my.camera_distance; // store the distance to the camera
if (my.health == 0) {my.health = 100;} // default health points = 100
if (my.camera_height == 0) {my.camera_height = 50;} // default camera_height value = 50
if (my.camera_distance == 0) {my.camera_distance = 250;} // default camera_distance value = 250
if (my.player_speed == 0) {my.player_speed = 3;} // default player_speed = 6
if (my.player_inertia == 0) {my.player_inertia = 0.5;} // default inertia = 0.5
if (my.player_rotation_speed == 0) {my.player_rotation_speed = 3;} // default player rotation speed = 5
if (my.player_climbing_speed == 0) {my.player_climbing_speed = 5;} // default player climbing speed = 5
if (my.dist_to_ground == 0) {my.dist_to_ground = 0;} // default distance between player's feet and the ground = 6 quants
if (my.pan_rotation_speed == 0) {my.pan_rotation_speed = 0.6;} // default camera rotation speed (pan) = 0.8
if (my.tilt_rotation_speed == 0) {my.tilt_rotation_speed = 5;} // default camera rotation speed (tilt) = 7
if (my.foot_step_distance == 0) {my.foot_step_distance = 59;} // default foot step distance = 59
while (my.health > 0) // as long as the player is alive
{
// rotate the player using the mouse, "A" and "D" or "cursor left" and "cursor right"
player.pan -= my.player_rotation_speed * mouse_force.x * time - 1.1 * ((key_cul || key_a) - (key_cur || key_d));
camera.x = player.x - my.camera_distance * cos(player.pan); // keep the camera behind the player
camera.y = player.y - my.camera_distance * sin(player.pan); // at the distance given by camera_distance
camera.z = player.z + my.camera_height + 0.8 * sin(my.skill46 * 3.6); // and above the player; 3.6 gives the head weaving amplitude
if (abs(ang(camera.pan) - ang(player.pan)) > 3) // need to rotate the camera quickly?
{
camera.pan += (player.pan - camera.pan) * my.pan_rotation_speed * time; // then do it!
}
else // no need for sudden camera rotations?
{
camera.pan += (player.pan - camera.pan) * my.pan_rotation_speed * 0.33 * time; // then rotate a bit slower
}
camera.tilt += my.tilt_rotation_speed * mouse_force.y * time; // the camera can tilt freely
my.camera_distance = min (max (my.camera_distance, 5), 1000); // camera_distance can have values between 5 and 1000
vec_set (temp.x, my.x); // copy player's position to temp
temp.z -= 5000; // set temp.z 5000 quants below player's origin
distance_to_ground = c_trace (my.x, temp.x, ignore_me | use_box); // compute the distance to ground

my.skill22 = my.player_speed * ((key_w || key_cuu) - (key_s || key_cud)); // move the player using "W" and "S" or "cursor up" and "cursor down"
my.skill21 = my.skill22 * time + max (1 - time * my.player_inertia, 0) * my.skill21; // compute speed
movement_speed.x = my.skill21 * time; // time correct the speed

movement_speed.y = 0; // don't move sideways
// the "space" key or the right mouse button are pressed and the player isn't jumping already?
if (((key_space == on) || (mouse_right == on)) && (now_jumping == 0))
{
perform_jump(); // then perform the jumping!
}
if (((key_space == off) && (mouse_right == off)) || (now_jumping == 0)) // space or the RMB aren't pressed anymore?
{
jump_height = max(0, jump_height - 12 * time); // use a smaller falling speed (15) for (potential) smaller jumps
if ((jump_height == 0) && (key_space == off) && (mouse_right == off)) // the player has touched the ground?
{
reached_height = 0; // then allow it to jump again
}
}
// my.dist_to_ground = 6, experimental value, puts player's feet on the ground
movement_speed.z = - (distance_to_ground - my.dist_to_ground) + min (200, jump_height);
movement_speed.z = min(4, movement_speed.z); // limit the movement speed on the z axis
movement_speed.z = max (-20 * time, movement_speed.z); // 20 = falling speed
if ((key_ctrl == on) && ((key_cuu == on) || (key_w == on))) // trying to climb up
{
vec_set (content_dist.x, player.x);
vec_set (temp, vector(20, 0, -20)); // check the content 20 quants in front of the player, 20 quants below its origin (-20)
vec_rotate(temp, vector(player.pan, 0,0));
vec_add (content_dist.x, temp.x); // content_dist is now set at player's feet, 20 quants in front of them
if (content (content_dist) == content_solid) // there's a wall in front of the player?
{
movement_speed.z = my.player_climbing_speed * time; // then start climbing!
}
}
my.skill47 += c_move (my, movement_speed.x, nullvector, glide); // move the player
if (my.skill47 > my.foot_step_distance) // adjust my.foot_step_distance (by default, we've got a step sound every 59 quants)
{
if ((jump_height == 0) && (movement_speed.z == 0)) // not jumping and not falling?
{
snd_play(step_wav, 20, 0); // then play the foot step sound
my.skill47 = 0; // reset the distance (increase the precission)
}
}
if (jump_height == 0) // the player isn't jumping?
{
if ((key_w == off) && (key_s == off) && (key_cuu == off) && (key_cud == off)) // the player isn't moving?
{
ent_animate(my, "stand", stand_percentage, anm_cycle); // play the "stand" animation
}
else // the player is moving?
{
if ((key_ctrl == on) && (content (content_dist) == content_solid)) // climbing?
{
// use a real "climb" animation here; I've only got "finish_him" for this model (although it looks good enough imo)
ent_animate(my, "attack", climb_percentage, anm_cycle);
}
else // not climbing?
{
ent_animate(my, "walk", walk_percentage, anm_cycle); // then play the "walk" animation
}
}
walk_percentage += 8 * ((key_w || key_cuu) - (key_s || key_cud)) * time; // 10 = animation speed
climb_percentage += 8 * time; // 10 = animation speed
jump_percentage = 0; // always start jumping with the first frame
}
else // the player is jumping
{
if (ascending == 1)
{
jump_percentage = jump_height / 2; // playing frames 1...50
stand_percentage = 0;
}
else // descending, playing frames 51...100
{
jump_percentage = min(100, (200 - jump_height) / 2); // limit the animation frame to 100
}
ent_animate(my, "jump", jump_percentage, anm_cycle); // play the "jump" animation
}
stand_percentage += 0.5 * time; // 5 = animation speed
avoid_obstacles(); // run the function that avoids camera collisions with the relief
wait (1);
}
// the player is dead here
my.skill40 = 0; // use skill40 to control the "death" animation
while (my.skill40 < 90) // don't play all the animation frames because the result doesn't look too good
{
ent_animate(my, "death", my.skill40, null);
my.skill40 += 2 * time; // "death" animation speed
camera.roll -= 0.3 * time; // rotate the camera
camera.tilt += 0.8 * time; // make it look up high in the sky
wait (1);
}
my.passable = on; // the corpse will be passable from now on
}

Re: Collision [Re: Mythran] #361977
03/06/11 00:39
03/06/11 00:39
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
First of all, use the [code] tags so that we don't have to try decoding a block of unspaced code.

But on to the question: c_move is already in the code. Just put the USE_POLYGON flag at the end of it.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Collision [Re: Redeemer] #361989
03/06/11 07:51
03/06/11 07:51
Joined: Sep 2006
Posts: 292
M
Mythran Offline OP
Member
Mythran  Offline OP
Member
M

Joined: Sep 2006
Posts: 292
Well, it all stays exancly the same as before..
Could be done anything else?

Re: Collision [Re: Mythran] #361993
03/06/11 08:27
03/06/11 08:27
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Ohh my God... Dude, do u understand how ur script above works?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Collision [Re: 3run] #361995
03/06/11 08:50
03/06/11 08:50
Joined: Sep 2006
Posts: 292
M
Mythran Offline OP
Member
Mythran  Offline OP
Member
M

Joined: Sep 2006
Posts: 292
Well, i'm no scripter, and although it's very explained, i'm very limited at
making changes...
I even added enable_polycollision = 2; at main function... but nothing...
So i guess the answer is no.

So if you guys would be more detailed i would be gratefull.

Thanks for you're comprehension.

Re: Collision [Re: Mythran] #361997
03/06/11 08:54
03/06/11 08:54
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Dude, u can't make game without understanding at least 60 % of script. Learn workshop, it'll take u about 3 - 5 hours to finish it.
Start from something smaller, make simple movement, try to add USE_POLYGON to it, and see how it changes. There is no other way to learn.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Collision [Re: 3run] #361998
03/06/11 09:02
03/06/11 09:02
Joined: Sep 2006
Posts: 292
M
Mythran Offline OP
Member
Mythran  Offline OP
Member
M

Joined: Sep 2006
Posts: 292
But i only need this piece of script to work... nothing else...
I always had a problem with collisions, as you might see from other posts...

I just cant seem to get collisions to work...
Is it so complicated?

Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | 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