1 registered members (AndrewAMD),
466
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
how do i make my model turn toward the enemy model?
#312435
02/24/10 19:31
02/24/10 19:31
|
Joined: Nov 2008
Posts: 196 the wrong place
Muhsin
OP
Member
|
OP
Member
Joined: Nov 2008
Posts: 196
the wrong place
|
Hi!
how do i make my model turn toward the enemy model? I tried to use this code:
---------------------------------- vec_set(enemypos, enemy.x); vec_sub(enemypos, my.x); vec_to_angle(my.pan, enemypos); my.tilt = 0; ------------------------------------
but when i try to run the level after writing that code, I get an error saying that the action crashed?
how do i do?
thanks!!!
- Muhsin Kaymak
Come and play my new browsergame - Valley Of Wolves: http://www.mafiacreator.com/ValleyOfWolvesHurry and be the first to take over the different business' in the Valley Of Wolves, before anybody else does it! And be the most feared MafiaBoss in the World!!
|
|
|
Re: how do i make my model turn toward the enemy model?
[Re: Muhsin]
#312437
02/24/10 19:43
02/24/10 19:43
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
make sure the enemypos,enemy and my is valid for that action
3333333333
|
|
|
Re: how do i make my model turn toward the enemy model?
[Re: alibaba]
#312464
02/24/10 22:49
02/24/10 22:49
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
enemypos could be a vector, in such case it doesnot really make a diffrence.
3333333333
|
|
|
Re: how do i make my model turn toward the enemy model?
[Re: Quad]
#312534
02/25/10 13:33
02/25/10 13:33
|
Joined: Nov 2008
Posts: 196 the wrong place
Muhsin
OP
Member
|
OP
Member
Joined: Nov 2008
Posts: 196
the wrong place
|
here is my code for the enemy:
----------------------------- action enemy_dummy() { enemy = my; while(1) {
wait(1); } } -------------------------------
and here is the code for the model:
-------------------------------- action player_machinegun_rotater() { my.group = 2; VECTOR enemypos; while(1) {
vec_set(enemypos, enemy.x); vec_sub(enemypos, my.x); vec_to_angle(my.pan, enemypos); my.tilt = 0; set(my,PASSABLE); wait(1); } } ------------------------------------------------
what am i doing wrong?
Come and play my new browsergame - Valley Of Wolves: http://www.mafiacreator.com/ValleyOfWolvesHurry and be the first to take over the different business' in the Valley Of Wolves, before anybody else does it! And be the most feared MafiaBoss in the World!!
|
|
|
Re: how do i make my model turn toward the enemy model?
[Re: Muhsin]
#312541
02/25/10 14:44
02/25/10 14:44
|
Joined: Oct 2005
Posts: 196
ambe
Member
|
Member
Joined: Oct 2005
Posts: 196
|
Try something like this-
VECTOR* My_Vector = {x=0;y=0;z=0;}
...
My_Vector.x = enemy.x - 3 * cos(my.x); // Play around with "3"
My_Vector.y = enemy.y - 3 * sin(my.x);
My_Vector.z = enemy.z;
vec_set (My_Vector.x, player.x);
vec_sub (My_Vector.x, my.x);
vec_to_angle (my.pan, My_Vector.x); // rotate it towards the target
...
Last edited by ambe; 02/25/10 14:46.
- code monkey
|
|
|
Re: how do i make my model turn toward the enemy model?
[Re: ambe]
#312547
02/25/10 15:00
02/25/10 15:00
|
Joined: Nov 2008
Posts: 196 the wrong place
Muhsin
OP
Member
|
OP
Member
Joined: Nov 2008
Posts: 196
the wrong place
|
it still doesn't work... could it be something in my script, i didn't write correct??
Come and play my new browsergame - Valley Of Wolves: http://www.mafiacreator.com/ValleyOfWolvesHurry and be the first to take over the different business' in the Valley Of Wolves, before anybody else does it! And be the most feared MafiaBoss in the World!!
|
|
|
Re: how do i make my model turn toward the enemy model?
[Re: mikaldinho]
#312587
02/25/10 16:17
02/25/10 16:17
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
@mika, stop the stupid comments, you have no idea what you are talking about.
@muhsin, send me the project i will look in to this.
3333333333
|
|
|
|