Spawning bullet at e.angle?
			9 posts			 • Page 1 of 1		
	
Spawning bullet at e.angle?
Well I want to spawn a bullet, that is rectangular in shape.
How do I spawn the bullet so it is at the same angle of the laser/box that is spawning it?
I'm sure there is some simple code.
			
		How do I spawn the bullet so it is at the same angle of the laser/box that is spawning it?
I'm sure there is some simple code.
- 
				

Dare - Posts: 833
 - Joined: Sat Nov 21, 2009 4:27 pm
 - Location: Sydney, Australia
 
Re: Spawning bullet at e.angle?
Search normal to angle function it thyme script forum
viewtopic.php?f=13&t=2900&start=0&hilit=normal+angle
			viewtopic.php?f=13&t=2900&start=0&hilit=normal+angle
Dream of Algodoo as game development engine...
		- 
				

Kilinich - [Best bug reporter 2010]
 - Posts: 2098
 - Joined: Mon Aug 31, 2009 8:27 pm
 - Location: South Russia
 
Re: Spawning bullet at e.angle?
- Code: Select all
 angle := math.atan(e.normal(1) / (e.normal(0) + 1)) * 2
- 
				

Rideg - Posts: 948
 - Joined: Tue Dec 15, 2009 5:17 pm
 - Location: Östersund, Sweden
 
Re: Spawning bullet at e.angle?
Rideg wrote:
- Code: Select all
 angle := math.atan(e.normal(1) / (e.normal(0) + 1)) * 2
aha, try this if e.normal = [-1,0]
Dream of Algodoo as game development engine...
		- 
				

Kilinich - [Best bug reporter 2010]
 - Posts: 2098
 - Joined: Mon Aug 31, 2009 8:27 pm
 - Location: South Russia
 
Re: Spawning bullet at e.angle?
Can't try for a few days what's the result?
			
		- 
				

Rideg - Posts: 948
 - Joined: Tue Dec 15, 2009 5:17 pm
 - Location: Östersund, Sweden
 
Re: Spawning bullet at e.angle?
Very complicated, but I used it in my S-Unit 2.0. It works quite well.
Should work (typed from memory), and stores the angle in controllerAcc. 0 is up (talking about normals here), clockwise is positive, counterclockwise is negative. Exactly ideal for air-friction stabilizers.
			- Code: Select all
 {math.asin(e.normal(0)) > 0} ? {controllerAcc = math.acos(e.normal(0))} : {controllerAcc = (-1) * (math.acos(e.normal(1)))}
Should work (typed from memory), and stores the angle in controllerAcc. 0 is up (talking about normals here), clockwise is positive, counterclockwise is negative. Exactly ideal for air-friction stabilizers.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
		I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
- 
				

Someone Else - Posts: 1147
 - Joined: Sun Nov 21, 2010 10:53 pm
 - Location: The Milky Way Galaxy
 
Re: Spawning bullet at e.angle?
Rideg wrote:Can't try for a few days what's the result?
the result will be a undefined result because of dividing by zero^^

- 
				

KarateBrot - Posts: 825
 - Joined: Mon Aug 31, 2009 7:32 pm
 - Location: Germany
 
Re: Spawning bullet at e.angle?
Kilinich wrote:Rideg wrote:
- Code: Select all
 angle := math.atan(e.normal(1) / (e.normal(0) + 1)) * 2
aha, try this if e.normal = [-1,0]
I just tested it. Strangely enough, I've been using that method for 6 months perhaps and never come across any issues with it.
- 
				

Rideg - Posts: 948
 - Joined: Tue Dec 15, 2009 5:17 pm
 - Location: Östersund, Sweden
 
Re: Spawning bullet at e.angle?
The only problem I can see with my code is that when the normal points down, it may give [math.pi] or [- math.pi]. But that should be easy to get around.
			Matthias Wandel is epic, in my humble opinion.
I love my brain...
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
		I love my brain...
TC42 wrote:Also, your sig is too big, please change it.
ARE YA HAPPY NOW?????
Thymechanic/Phundamentalist
Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
- 
				

Someone Else - Posts: 1147
 - Joined: Sun Nov 21, 2010 10:53 pm
 - Location: The Milky Way Galaxy
 
			9 posts			 • Page 1 of 1		
	Who is online
Users browsing this forum: No registered users and 7 guests





