|
|
Re: How to aim in 3rd person shooter
[Re: MAGA]
#247928
01/23/09 13:25
01/23/09 13:25
|
Joined: Nov 2008
Posts: 946
the_clown
User
|
User
Joined: Nov 2008
Posts: 946
|
Excuse me for this, I just have forgotten this.... I am so ashamed. However, let's see. You want the model to play the "aim" animation, turn to the next enemy and you want the enemy to be selected by a circle, right.
I don't know how your code looks like, but I suppose you have a loop running in the player action. Now, in this loop, you have to check if the player is pressing a certain key. Then you have to check for the enemies, turn the player to the nearest one and play the animation:
first, define a entity:
ENTITY* selected_enemy;
//////////////////////////////////////////////////////////////////// if(mouse_right) { c_scan(my.x,my.pan,vector(360,360,3000),IGNORE_PASSABLE); if(you) { if(you.skill6 == 1) // the enemy should have set skill6 to 1 { selected_enemy = you; vec_set(temp,your.x); vec_sub(temp,my.x); vec_to_angle(my.pan,temp); // now MY looks at YOU my.tilt = 0; vec_set(my.move_x,vector(0,0,0)); //replace move_x with the skill you are using for moving my.skill3 += 20*time_step; // blend factor for 1-frame animation my.skill3 = min(my.skill3,100); // clip at 100 percent } } } else { my.skill3 -= 20*time_step; my.skill3 = max(my.skill3,0); // clip at 0 percent }
ent_blend("aim",0,my.skill3); /////////////////////////////////////////////////////////////////////////////
you should put this whole code snippet (exept for the entity definition) at the end of your player loop (but before the wait(1) of course).
for the circle just define a panel with the circle bitmap and write a function that permanently sets the world coordinates of the selected_enemy entity to 2d coordinates. (vec_to_screen). I'm sorry if this doesn't work right, just post then. I've put this together in ten minutes using the online manual and my memories; I don't have access to my own code now.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|