I use vectorToAngle for shooting, but I don't know how it works. Knowing could help me, since my game's shooting is going wonky. So what is vectorToAngle, and how does it work?
svn said: I use vectorToAngle for shooting, but I don't know how it works. Knowing could help me, since my game's shooting is going wonky. So what is vectorToAngle, and how does it work?
Basically, it can be used to compare two points and getting the angle between them.
It starts out like this... vectorToAngle(x, y)
For x... you can put the X locations for the two points...
game.Mouse.Position.X - self.location.X
Then the same can be done for the Y values...
game.Mouse.Position.Y - self.location.Y
The full formula could then be thrown in the "Angle" field of a "Rotate To Angle" behavior...
The Unofficial GameSalad Textbook has more information on this matter... like a chart to illustrate what's going on and examples of how vectorToAngle is useful.
When vectorToAngle doesn't seem to be working properly for me, I check to see if I put the attributes in the right order... game.Mouse.Position.X - self.location.X is not the same as self.location.X - game.Mouse.Position.X.
Oh, it was! I was just commenting on fzeed and calvin9403's posts. But now there's one problem: the closer the actor gets to the mouse, the further back the bullets move, up to the point of moving in the opposite direction! What should I do?
tenrdrmerMember, Sous Chef, Senior Sous-ChefPosts: 9,934
What do you need help with svn? Photics answered your question. You mean move to cookbook? Simple. You can't move it. LOL
The cookbook is a whole different system than the forum. If you want to add the question you can go to the cookbook and scroll to the bottom and click add question. Then people will answer it. Although. The thing im not quite liking about the cookbook is we cannot seem to sort any of the questions. Say Maybe I want to go add Answers. I have to scroll through every single question and see if it has been answered. Really nee to have a new questions area and a way to sort by how many answers something has. IMO
Comments
It starts out like this... vectorToAngle(x, y)
For x... you can put the X locations for the two points...
game.Mouse.Position.X - self.location.X
Then the same can be done for the Y values...
game.Mouse.Position.Y - self.location.Y
The full formula could then be thrown in the "Angle" field of a "Rotate To Angle" behavior...
vectorToAngle(game.Mouse.Position.X - self.location.X, game.Mouse.Position.Y - self.location.Y)
The actor will then rotate to face the mouse.
The Unofficial GameSalad Textbook has more information on this matter... like a chart to illustrate what's going on and examples of how vectorToAngle is useful.
When vectorToAngle doesn't seem to be working properly for me, I check to see if I put the attributes in the right order... game.Mouse.Position.X - self.location.X is not the same as self.location.X - game.Mouse.Position.X.
Also, depending on the scenario, the "Rotate To Position" behavior can be an alternative to vectorToAngle.
also check out this video
_______________________
http://www.thatgameforum.com/
http://gshelper.com/
http://www.youtube.com/user/GameSaladCookbook#p/
http://gamesalad.com/wiki/
http://www.deepblueapps.com/Deep_Blue_Ideas_Ltd./Home.html
http://www.gamesalad.es/
http://thatgameforum.com/threads/gs-videos.360/
These are great question to ask on Cookbook. We're encouraging people to ask their "how tos" and "why does it do this" questions there. Thanks!
__________________________
http://www.thatgameforum.com/
http://gshelper.com/
http://www.youtube.com/user/GameSaladCookbook#p/
http://gamesalad.com/wiki/
http://www.deepblueapps.com/Deep_Blue_Ideas_Ltd./Home.html
http://www.gamesalad.es/
http://thatgameforum.com/threads/gs-videos.360/
my email: calvin9403@hotmail.com
Simple. You can't move it. LOL
The cookbook is a whole different system than the forum. If you want to add the question you can go to the cookbook and scroll to the bottom and click add question. Then people will answer it. Although. The thing im not quite liking about the cookbook is we cannot seem to sort any of the questions. Say Maybe I want to go add Answers. I have to scroll through every single question and see if it has been answered. Really nee to have a new questions area and a way to sort by how many answers something has. IMO