My student is having trouble with his game and I don’t knwo what to tell him…
He wants to shoot the arrow from the character, but he cant figure out how to make the arrow move AND have the arrow reset to the players position so it only shoots from the player…
Anyone able to help him???
Here is one way to do it. See the notes below and the comments in the code for explanations.
Notes:
- Student had mixed up playerleft and playerright animations, so I swapped the names to make it is less confusing.
- I use an arrowMoving variable to indicate direction arrow is moving
- Pressing SPACE resets the arrow and fires in the direction player is facing.
- Code added to prevent arrow from changing direction mid-flight.
Feel free to ask clarifying questions, if necessary. LMK how it goes.
John
P.S. I just realized this question is about 7 years old…maybe it will still help someone.