3 registered members (AndrewAMD, VoroneTZ, 1 invisible),
1,512
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
another 2 problems
#137797
06/24/07 09:31
06/24/07 09:31
|
Joined: Jul 2006
Posts: 111 Germany near Wuerzburg
Disaster
OP
Member
|
OP
Member
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
|
Hi I have another 2 problems... the first problem is that my enemy entitys don't move over the screen and the second problem is the collision with the player. nothing happens when i touch with my player an enemy. But when there are 30 enemys in the script (because they become more and more during the game) suddenly my player disappears like he should do after a collision with an enemy. my code (mostly taken from the book of tobias runde; i know it's not up to date but nevertheless it helps sometimes ): define speed, skill1; define direction, skill2; var distance[3]; action enemy { my.push = -1; my.z = 32; my.passable = on; If (my.speed == 0) { my.speed = random(6)+3; } my.direction = 1; my.pan += random(my.richtung)*time*my.direction; distance.x = time*my.speed; distance.y = 0; distance.z = 0; vec_set(temp,my.x); if (vec_dist(my.x, player.x) < 35) { ent_remove(player); } } action player { player = me; my.enable_impact = on; wait(1); while(player != NULL) { my.push = -1; ... } }
mfg
Disaster
|
|
|
Re: another 2 problems
[Re: Disaster]
#137798
06/24/07 10:25
06/24/07 10:25
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
Code:
while(my) {
If (my.speed == 0) { my.speed = random(6)+3; } my.direction = 1; my.pan += random(my.richtung)*time*my.direction; distance.x = time*my.speed; distance.y = 0; distance.z = 0; vec_set(temp,my.x); if (vec_dist(my.x, player.x) < 35) { ent_remove(player); }
wait(1); }
1) You have to put the above code (red color) in a while loop to let them move continously. 2) You need an event function when player is collided by enemies, for example : Code:
player = me; my.enable_impact = on;
my.event = hitme;
wait(1); while(player != NULL) { my.push = -1; ... } function hitme() // put this function above your actions { if (event_type == event_impact) { ..... ..... } }
|
|
|
Re: another 2 problems
[Re: vlau]
#137799
06/24/07 13:49
06/24/07 13:49
|
Joined: Jul 2006
Posts: 111 Germany near Wuerzburg
Disaster
OP
Member
|
OP
Member
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
|
hi I put the red code in a while loop as you described it and i also wrote a simple event but the two problems are stioll there. the enemys don't move and the don't "kill" the player...
mfg
Disaster
|
|
|
Re: another 2 problems
[Re: Disaster]
#137800
06/24/07 14:53
06/24/07 14:53
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
Ah, I'm overlook this line : distance.x = time*my.speed; change it to distance.x += time*my.speed, but then again it will move forward only about the world axis, no matter what my.pan is facing, you may need to use c_move instead, and in fact, the even_impact function won't trigger without c_move.
Last edited by vlau; 06/24/07 14:58.
|
|
|
Re: another 2 problems
[Re: vlau]
#137801
06/24/07 15:26
06/24/07 15:26
|
Joined: Jul 2006
Posts: 111 Germany near Wuerzburg
Disaster
OP
Member
|
OP
Member
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
|
ok now they are moving^^ thank you to the direction: i have a simple room and you play a ball who has to catch a cube. when you catch it one more enemy appears and "walks" along in this room and kills you when you hit it. so i think a movement only forwards is enough, because the enemys only have to change their move-directing when they hit a wall. I wanted to do this with "bounce" ...but i have no idea how to code this i simply want to write a game like this in 3d: http://www.lewpen.com/game/perhaps than it's easier to understand
mfg
Disaster
|
|
|
Re: another 2 problems
[Re: Disaster]
#137802
06/24/07 15:50
06/24/07 15:50
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
Oh interesting game I think writing games has a lot of fun and if you can make it by yourself will be a big big fun, so I suggest try it yourself, it won't be too difficult. I'll say using c_move plus even_impact/event_entity for your moveable entities is a good way to go. Good luck!
|
|
|
Re: another 2 problems
[Re: vlau]
#137803
06/24/07 19:12
06/24/07 19:12
|
Joined: Jul 2006
Posts: 111 Germany near Wuerzburg
Disaster
OP
Member
|
OP
Member
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
|
hm...now they are moving to to the wall, but very very fast and sometimes they even bounce but only sometimes...the most time they are hanging in a corner. Do you know a tutorial where bounce is explained, because i really have no idea who to use it...
mfg
Disaster
|
|
|
Re: another 2 problems
[Re: Disaster]
#137804
06/24/07 21:29
06/24/07 21:29
|
Joined: Jul 2006
Posts: 111 Germany near Wuerzburg
Disaster
OP
Member
|
OP
Member
Joined: Jul 2006
Posts: 111
Germany near Wuerzburg
|
ok now the code works nearly perfect. But how can i prevent that the enemys bounce in z-direction? because sometimes they are flying out of my level. another little problem is the collision with the player because the programm even detects a collision when the two objects are close together but don't touch. how can i change this?
mfg
Disaster
|
|
|
Re: another 2 problems
[Re: Disaster]
#137805
06/25/07 08:16
06/25/07 08:16
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
Hello Disaster, You can find a lot of tips about c_move and bounce in Aum's faq list Go there, press CTRL-F, and type "bounce". Also try bounce.z = 0 to prevent bounce to z-axis, not tested btw. Quote:
another little problem is the collision with the player because the programm even detects a collision when the two objects are close together but don't touch. how can i change this?
May be reset their bounding box using c_setminmax(my), put it into the first line of your action :
action ballEntity { c_setminmax(my); ..... ..... }
Last edited by vlau; 06/25/07 09:08.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|