Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 10:32
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip, Quad), 604 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Bullet impacting crate #207249
05/18/08 18:10
05/18/08 18:10
Joined: Aug 2003
Posts: 716
Canada, Toronto
thegamedesigner Offline OP
User
thegamedesigner  Offline OP
User

Joined: Aug 2003
Posts: 716
Canada, Toronto
Hello, I have some code in place for a crate, and a bullet hitting the crate, but I can't seem to figure out exactly what force I should give the crate.

I am trying to make the crate react to the bullet hit. Here is my code:

action crate_act
{
my.category = 11;
phent_settype(my,ph_rigid,ph_box);
phent_setmass(my,5,ph_box);
//phent_enable(my,1);
phent_setfriction (my, 40);
phent_setdamping(my, 20, 20);
phent_setelasticity (my, 0, 40);
phent_setgroup(my, 1);//1,2,4,8,8
ph_selectgroup(1);
}

... Bullet code (target is point of impact, sloc[3] is where the bullet came from):
...
//Bullet has hit something, is it a crate?
if(you.category == 11)//It is a crate.
{
var dir[3];
dir[0] = 1;
vec_rotate(dir,vector(pan1[0],0,0));
vec_normalize(dir,60000*time);
phent_addforcelocal(you,vector(320,0,0),target);
}
...

This is going to be so useful when it's done, thanks for all help.

EDIT: Pan1[3] contains the bullet's current pan/tilt/roll.

Last edited by thegamedesigner; 05/18/08 18:11.

My games - www.spyeart.com
Re: Bullet impacting crate [Re: thegamedesigner] #207306
05/19/08 03:25
05/19/08 03:25
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
phent_addforceglobal (ENTITY* entity,VECTOR* vForce,VECTOR* vPos );

vForce being the direction and strength of the force:
- vForce = normalize(target - source, strength);

And vpos being the position where it hit the entity:
- vPos = target;


xXxGuitar511
- Programmer
Re: Bullet impacting crate [Re: xXxGuitar511] #207432
05/19/08 16:10
05/19/08 16:10
Joined: Aug 2003
Posts: 716
Canada, Toronto
thegamedesigner Offline OP
User
thegamedesigner  Offline OP
User

Joined: Aug 2003
Posts: 716
Canada, Toronto
Alright, I fiddled with that, and ended up with this:

vec_set(dir,pan1);//pan1 is the .pan,tilt and roll of the bullet
vec_inverse(dir);
vec_normalize(dir, 25000);
phent_addforceglobal (you,dir,target);

That seems to work, but there is something funny about it. Does it look like I got it right?

Thanks for the help btw,


My games - www.spyeart.com
Re: Bullet impacting crate [Re: thegamedesigner] #207603
05/21/08 03:38
05/21/08 03:38
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
...Looks right. Whats funny about it? The reaction?


xXxGuitar511
- Programmer
Re: Bullet impacting crate [Re: xXxGuitar511] #207668
05/21/08 15:58
05/21/08 15:58
Joined: Aug 2003
Posts: 716
Canada, Toronto
thegamedesigner Offline OP
User
thegamedesigner  Offline OP
User

Joined: Aug 2003
Posts: 716
Canada, Toronto
Sometimes when I fire fast at it, it becomes airborne. Fine, np, but sometimes it moves away from me, and other times it spins towards me.

I am going to increase the weight/decrease the force, so it can't become airborne, but it is annoying.

Anyway, thanks very much for you help, I have crates that move when you shoot them.


My games - www.spyeart.com

Moderated by  HeelX, Spirit 

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