Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
0 registered members (), 1,012 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Smooth aiming transition??? #334272
07/22/10 08:19
07/22/10 08:19
Joined: Apr 2005
Posts: 795
U.S.A. Michigan
exile Offline OP
User
exile  Offline 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: exile] #334285
07/22/10 10:22
07/22/10 10:22
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
Ok you want that the player just aims to those vector coordinates? And if not he aims to the other vector?

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 Offline

3D Artist
rvL_eXile  Offline

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: rvL_eXile] #334353
07/22/10 17:26
07/22/10 17:26
Joined: Apr 2005
Posts: 795
U.S.A. Michigan
exile Offline OP
User
exile  Offline OP
User

Joined: Apr 2005
Posts: 795
U.S.A. Michigan
Kind of. You see, I am trying to achieve an "Iron sight" type of aiming seen in the Call of duty series as well as other games. Those vector coordinates are for the weapon model's position relative to the camera/player. I was looking into vec_add but I dont know how to use it.

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 Offline OP
User
exile  Offline 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] #334569
07/23/10 23:58
07/23/10 23:58
Joined: Apr 2005
Posts: 795
U.S.A. Michigan
exile Offline OP
User
exile  Offline OP
User

Joined: Apr 2005
Posts: 795
U.S.A. Michigan
Please???

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 Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
this should work:

Code:
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
Re: Smooth aiming transition??? [Re: painkiller] #334965
07/26/10 02:05
07/26/10 02:05
Joined: Apr 2005
Posts: 795
U.S.A. Michigan
exile Offline OP
User
exile  Offline OP
User

Joined: Apr 2005
Posts: 795
U.S.A. Michigan
Thank you for the code. I found another way to do it though. Basically, I defined the weapons Y position vector to a variable which I just dynamically adjust during runtime. It looks great and it's very fast as well. I want to thank everyone who helped me out in this situation!!!


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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