Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 485 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
bounce back from enemy --need help #307970
02/01/10 00:20
02/01/10 00:20
Joined: Jun 2009
Posts: 38
H
hungryhobo Offline OP
Newbie
hungryhobo  Offline OP
Newbie
H

Joined: Jun 2009
Posts: 38
hello, I have a script that hurts the player when they are hit by an entity, but i want the player to bounce back in the opposite direction of the entity hitting it.

how can i calculate the force vector to bounce back from being hit? I am using the physics engine.

this is what i have so far:

function bounce_back()
{
//point player towards object
vec_set(temp.x, you.x);
vec_sub(my.x, temp.x);
vec_to_angle(my.pan, temp.x);

var back_force;

vec_set(back_force.x, my.pan);
//take the pan and make it negative, multiply
vec_normalize(back_force, -10000000);

phent_addcentralforce(me, back_force.x);
}

tips would be appreciated. thank you

Re: bounce back from enemy --need help [Re: hungryhobo] #307989
02/01/10 07:30
02/01/10 07:30
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655

Code:
// C-Script?
ENTITY* eSrc;
ENTITY* eTarget;
//var temp[3];
function bounce_back(_eSrc, _eTarget, _nForce) {
	eSrc = _eSrc;
	eTarget = _eTarget;
	vec_diff(temp, eSrc.x, eTarget.x);	// temp points at eSrc?
	vec_normalize(temp, _nForce);
	
	phent_addcentralforce(eSrc, temp); //???
}

//...
bounce_back(me, you, 15); // ??



Re: bounce back from enemy --need help [Re: hungryhobo] #308167
02/01/10 23:02
02/01/10 23:02
Joined: Jun 2009
Posts: 38
H
hungryhobo Offline OP
Newbie
hungryhobo  Offline OP
Newbie
H

Joined: Jun 2009
Posts: 38
thanks for helping me! works like a charm and now i know how to add parameters for functions in c-script.

i really appreciate it.


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