Browse Search Popular Register Upload Rules User list Login:
Angle gun with bug

screenshot of the scene

Author: Jelmerholland

Group: Default

Filesize: 13.24 kB

Date added: 2009-07-10

Rating: 5

Downloads: 351

Views: 714

Comments: 5

Ratings: 1

Times favored: 0

Made with: Phun


Scene tag

Why doesn't this work?

Q: change the motorspeed and let the gun turn to left. Why I have this bug?
A: becuz the angle is negative

Q: why doesn't it work at the 0 < x < 45
A: ....

Q: How can I solve it?
A: ....

I hope that you can help me:s Because I want this gun for my next mouse controlled ufo
Please log in to rate this scene
Similar scenes
Title: Gyroscope
Rating: 6.4
Filesize: 65.09 kB
Downloads: 1176
Comments: 1
Ratings: 4
Date added: 2009/04/28 12:55:48
Made with: Phun
Rating: rated 6.4
Title: Artillery Game
Rating: 8.1003
Filesize: 377.62 kB
Downloads: 4790
Comments: 19
Ratings: 23
Date added: 2009/05/04 04:59:10
Made with: Phun
Rating: rated 8.1
Title: P.H.U.N. Angle Tracker
Rating: 6.1111
Filesize: 10.31 kB
Downloads: 420
Comments: 0
Ratings: 3
Date added: 2009/07/05 02:07:45
Made with: Phun
Rating: rated 6.1
Title: Artillery
Rating: 6.9167
Filesize: 35.16 kB
Downloads: 457
Comments: 7
Ratings: 6
Date added: 2009/11/08 04:56:00
Made with: Algodoo before v1.8.5
Rating: rated 6.9
Title: Hetzer
Rating: 5
Filesize: 85.6 kB
Downloads: 640
Comments: 0
Ratings: 1
Date added: 2014/01/15 10:13:46
Made with: Algodoo v2.1.0
Rating: rated 5
Title: mortar (looks better and better ammo)
Rating: 5
Filesize: 472.09 kB
Downloads: 437
Comments: 0
Ratings: 1
Date added: 2014/07/04 00:25:22
Made with: Algodoo v2.1.0
Rating: rated 5
you need to get the angle between 2 points (mousepos, pos) and compare it with the normal-only angle. you sould know how to do the normal only angle, but, it can be simplified if you are only using e. normal, to:

math.atan(e.normal(1) / (e.normal(0) + 1)) * 2

because the length of the e.normal vector is always 1. for vectors with variable lengths you need to use the other one.

hovewer, ive not managed to think of a math formula to measure the angle betweeen those 2 points.

Another thing you should be aware of is that phun measures angles in radians, so, you might need radians and not degrees to do it
Aha, but the problme is that the bullets allways go to the right.. where the deg are possitive.. I think I have to add 180 or smth like that
for bullet speed you can use e.normal - no complicated stuff here
Okay.. but the problem is this.. when the gun is aimed to the left... the gun doesn't work... the speed is allways possitive... never negative... but Can I solve this by e.normal -300 for example??
actually, e.normal returns the vector of the collision detection in two vectors.You can't go wrong with it, because the distance between the position and the position + the normal is always equal to 1 meter.

if you're trying ro get the bullet at a constant 300 m/s rate, it would be "e,normal * 300"(notice the multiplication