Gamestudio Links
Zorro Links
Newest Posts
Why Zorro supports up to 72 cores?
by 11honza11. 04/26/24 08:55
M1 Oversampling
by 11honza11. 04/26/24 08:32
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, VoroneTZ, Quad, 1 invisible), 805 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
simple weapon? #173914
12/19/07 22:15
12/19/07 22:15
Joined: Mar 2007
Posts: 99
Germany
zSteam Offline OP
Junior Member
zSteam  Offline OP
Junior Member

Joined: Mar 2007
Posts: 99
Germany
hi

i want to write a weapon script to push physic objects away. how can i solve this problem?

hallo

ich möchte ein waffenskript schreiben, damit ich physikobjekte wegstoßen kann. doch wie kann ich das erreichen?


=> www.alrik-online.de
A7 Commercial
Re: simple weapon? [Re: zSteam] #173915
12/20/07 12:05
12/20/07 12:05
Joined: Jul 2006
Posts: 503
Australia
A
adoado Offline

User
adoado  Offline

User
A

Joined: Jul 2006
Posts: 503
Australia
Depends on what physics engine you are using, Newton or ODE?

If you are using newton, I found this code in one of my old projects:

Code:

var toss_speed=100;//push speed and force
var toss_force=25;
var react_dist=50; //player pushes objects closer than this distance


action NewtonBox()
{

.....

var body;
while(1)
{
body = NewtonGetBody (my);
if (body)
{
if(player) //if player exists on the level
{
if (vec_dist(my.x,player.x)<react_dist)
{
newtonImpulseRecord[0] = my.x;
newtonImpulseRecord[1] = my.y;
newtonImpulseRecord[2] = my.z;

newtonImpulseRecord[3] = player.x;
newtonImpulseRecord[4] = player.y;
newtonImpulseRecord[5] = player.z - 0.25;

newtonImpulseRecord[6] = toss_speed;

newtonImpulseRecord[7] = toss_force;

NewtonBodyAddImpulse (body, newtonImpulseRecord);
}
}
}
}
}



I cannot remember how good it worked, but it should get you started

Thanks,
Adoado


Visit our development blog: http://yellloh.com
Re: simple weapon? [Re: adoado] #173916
12/20/07 17:19
12/20/07 17:19
Joined: Mar 2007
Posts: 99
Germany
zSteam Offline OP
Junior Member
zSteam  Offline OP
Junior Member

Joined: Mar 2007
Posts: 99
Germany
hi thx for the answer ... but i want to use ODE


=> www.alrik-online.de
A7 Commercial
Re: simple weapon? [Re: zSteam] #173917
12/20/07 18:25
12/20/07 18: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
What kind of push

..Like a force that continually pushes, or an impact (as if something hit it) ?


xXxGuitar511
- Programmer
Re: simple weapon? [Re: xXxGuitar511] #173918
12/20/07 18:41
12/20/07 18:41
Joined: Mar 2007
Posts: 99
Germany
zSteam Offline OP
Junior Member
zSteam  Offline OP
Junior Member

Joined: Mar 2007
Posts: 99
Germany
an imapct.... i would like to write a actionshooter with physic objects like HL2


=> www.alrik-online.de
A7 Commercial
Re: simple weapon? [Re: zSteam] #173919
12/21/07 19:14
12/21/07 19:14
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
...well then, let me take a look in the manual...


phent_addforceglobal (ENTITY* entity, VECTOR* vForce, VECTOR* vPos );


...I'm not entirely sure of this, but I think this is what you need. Of course set ENTITY to the target physics ent.

Set FORCE to the bullet direction, and it's magnitude to the force. To do the latter, use vec_normalize(vector, 1000); 1000 being a random guess for force

and vPOS to the point where it hit the entity.


xXxGuitar511
- Programmer

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