Rotating the normal?
4 posts • Page 1 of 1
Rotating the normal?
Hello I'm making a "gun" and I've got the "fire" spawner wich spawns a bullet and launches it towards the target.
Now, the spawner has a laser that's triggering it and it's pointed from the right to the spawner.
How can I make the shells to have a velocity that's pointing down? Consider that the gun is rotatable so the "down" vector isn't always down if you have aimed upwards, it wont be pointed vertically. I'm using the right laser triggering to make the bullets go with a velocity * the normal so I can't use that.
Thank you for taking your time reading this
-Johan
Now, the spawner has a laser that's triggering it and it's pointed from the right to the spawner.
How can I make the shells to have a velocity that's pointing down? Consider that the gun is rotatable so the "down" vector isn't always down if you have aimed upwards, it wont be pointed vertically. I'm using the right laser triggering to make the bullets go with a velocity * the normal so I can't use that.
Thank you for taking your time reading this
-Johan
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Rotating the normal?
As I know
So try to go this way
It works! I have check)
___________
PS
Instead -1.571 You can place number in radians or formula
So there is the same as
___________
PPS
More correct code is
___________
PPPS
- Code: Select all
normal = [cos, sin]
So try to go this way
- Code: Select all
math.atan(e.normal(1)/e.normal(0)) // angle
math.atan(e.normal(1)/e.normal(0))-1.571 // 1,571 rad = 90 degree
// So in the end we have
vel:=[math.cos(math.atan(e.normal(1)/e.normal(0))-1.571), math.sin(math.atan(e.normal(1)/e.normal(0))-1.571)]
It works! I have check)
___________
PS
Instead -1.571 You can place number in radians or formula
- Code: Select all
(A/180*Math.Pi)
// A - number in degrees
So there is the same as
- Code: Select all
vel:=[math.cos(math.atan(e.normal(1)/e.normal(0))-(90/180*Math.Pi)), math.sin(math.atan(e.normal(1)/e.normal(0))-(90/180*Math.Pi))]
___________
PPS
More correct code is
- Code: Select all
vel:=e.normal(0)>0?{[math.cos(math.atan(e.normal(1)/e.normal(0))-1.571), math.sin(math.atan(e.normal(1)/e.normal(0))-1.571)]}:{[math.cos(math.atan(e.normal(1)/e.normal(0))-1.571), math.sin(math.atan(e.normal(1)/e.normal(0))-1.571)]*(-1)}
___________
PPPS
Last edited by Nait on Thu Oct 07, 2010 2:21 am, edited 1 time in total.
-
Nait - Posts: 224
- Joined: Fri Oct 30, 2009 1:56 am
- Location: Eastern Russia, Vladivostok
Re: Rotating the normal?
Thank you Best answer I've got to any question. I think. Biggest thanks
make sure to check out my work.
-
Rideg - Posts: 948
- Joined: Tue Dec 15, 2009 5:17 pm
- Location: Östersund, Sweden
Re: Rotating the normal?
I'm not very expired in scripts, but if I know something, I will be glad to share
-
Nait - Posts: 224
- Joined: Fri Oct 30, 2009 1:56 am
- Location: Eastern Russia, Vladivostok
4 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 11 guests