|
0 registered members (),
1,012
guests, and 8
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Smooth aiming transition???
#334272
07/22/10 08:19
07/22/10 08:19
|
Joined: Apr 2005
Posts: 795 U.S.A. Michigan
exile
OP
User
|
OP
User
Joined: Apr 2005
Posts: 795
U.S.A. Michigan
|
I am trying to have the weapon move smoothly to the aiming position when the player presses the "aim" button. The current code I have just sort of... pops the weapon into position. I have tried to do this myself but all that happens is my weapon flys off into the world somewhere. How can I do this? Here is my code...
if(mouse_right == 0) { vec_set (my.x, vector (50, -50, -50)); // Gun position (Out/In,L/R,U/D) } if(mouse_right == 1) { vec_set (my.x, vector (50, 0, -45)); // Gun position (Out/In,L/R,U/D) }
|
|
|
Re: Smooth aiming transition???
[Re: Rasch]
#334335
07/22/10 15:53
07/22/10 15:53
|
Joined: Apr 2005
Posts: 3,076 Germany, NRW
rvL_eXile

3D Artist
|

3D Artist
Joined: Apr 2005
Posts: 3,076
Germany, NRW
|
Do you want to set the Aiming Focus at a defined Position ? If i understand you correctly, you want to aim to maybe an Entity which has for example the coordinates X=100 / Y=200... But the Croshair is fixed in the middle of the Screen and is currently located at (example) X=50 / Y=100;
Soooo.... Now i would calculate how big are the difference between this two values is, and create an function which handles the "movement". With an while Loop you should check if the Value of the Entity is bigger than your crosshair position. Now move the player.pan (crosshair) into the direction in how many steps like you have calculated...
Hopely you understand it a bit ^^
cYa Sebastian
Tutorials: [Blender]Terrain creation ENG/GER [Blender]Low Poly Tree Modeling [GIMP]Create a Texture for Terrains CLICK HERE
|
|
|
Re: Smooth aiming transition???
[Re: exile]
#334496
07/23/10 17:44
07/23/10 17:44
|
Joined: Apr 2005
Posts: 795 U.S.A. Michigan
exile
OP
User
|
OP
User
Joined: Apr 2005
Posts: 795
U.S.A. Michigan
|
Anyone? Is there any way to smoothly move an entity placed by the vec_set function?
Also I have another problem. I would like a sound to play when an entity is at the highest amplitude of its sin movement. How would I do that???
Last edited by exile; 07/23/10 19:01.
|
|
|
Re: Smooth aiming transition???
[Re: exile]
#334571
07/24/10 00:14
07/24/10 00:14
|
Joined: Aug 2009
Posts: 1,438 Spain
painkiller
Serious User
|
Serious User
Joined: Aug 2009
Posts: 1,438
Spain
|
this should work:
var speed; //speed to move the entity
var newpos_vector[3]; //position of aim active
previouspos_vector[3]; //position without aim
move_vector[3]; //used to store the movement
var aim=0; //aim actived or not?
if(mouse_right)
{
vec_diff(move_vector, newpos_vector, previouspos_vector);
vec_normalize(move_vector, speed);
aim=1;
}else{
vec_diff(move_vector, previouspos_vector, newpos_vector);
vec_normalize(move_vector, speed);
aim=0;
}
if(aim==0) if(vec_dist(entity, previouspos_vector)>0.1)
{
c_move(entity, nullvector, move_vector, IGNORE_ME|IGNORE_PASSABLE);
}else{
vec_set(move_vector, nullvector);
}
if(aim==1) if(vec_dist(entity, newpos_vector)>0.1)
{
c_move(entity, nullvector, move_vector, IGNORE_ME|IGNORE_PASSABLE);
}else{
vec_set(move_vector, nullvector);
}
3D Gamestudio A8 Pro AMD FX 8350 4.00 Ghz 16GB RAM Gigabyte GeForce GTX 960 4GB
|
|
|
|