Adding force to appropriate direction.

For questions about using Classic.

Post » Sat Feb 21, 2009 6:41 pm

I have a bullet that shoots from the player and the angle of that bullet is judged by which way it shoots (Mouse controlled). This is a platform shooter and when i shoot the box i'm trying to figure out how to make it apply force to the appropriate direction (If bullet comes from left of the box it pushes the box to the right etc.)
B
1
G
3
Posts: 6
Reputation: 837

Post » Sat Feb 21, 2009 6:55 pm

I don't get what you mean, but if you are using physics (which I assume, as you speak of adding force), you would want to use "Set force toward position" and use MouseX & MouseY coordinates.

Edit:
Okay, let me see if I got it right...
1. Shoot a bullet
2. Bullet collides with box and applies force to it
3. Box reacts to the force

In that case, you want an on collision event with "set force" action on box:

X component = ForceAmount*cos(AngleBetweenBulletandBox)
Y component = ForceAmount*sin(AngleBetweenBulletandBox)

ForceAmount could be the bullet's X or Y component of the speed.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sat Feb 21, 2009 9:28 pm

Thanks! It works but when i shoot at the top of the box it doesnt like "flip" over.
B
1
G
3
Posts: 6
Reputation: 837

Post » Sat Feb 21, 2009 11:12 pm

[quote="Xama":1ra0mlhu]Thanks! It works but when i shoot at the top of the box it doesnt like "flip" over.[/quote:1ra0mlhu]

You'd have to apply an angular velocity for that. That would require some fancy math I can't seem to figure up at the moment.
Moderator
B
99
S
37
G
19
Posts: 1,584
Reputation: 17,842

Post » Sat Feb 21, 2009 11:29 pm

[quote="linkman2004":1p6td049][quote="Xama":1p6td049]Thanks! It works but when i shoot at the top of the box it doesnt like "flip" over.[/quote:1p6td049]

You'd have to apply an angular velocity for that. That would require some fancy math I can't seem to figure up at the moment.[/quote:1p6td049]

aww. Thanks for the help though.
B
1
G
3
Posts: 6
Reputation: 837

Post » Mon Feb 23, 2009 11:52 pm

bump
B
1
G
3
Posts: 6
Reputation: 837


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests