Need help with shootin and trigonometry

Ryzhoff

  • Posts: 54
Hello,
Can you please explain me how can I create "bullet" in the same point no matter how my basic actor rotated. You will better understand what I need if you show attachments/

Ryzhoff

  • Posts: 54

Ganu

  • Posts: 224
I think some exerienced users (aka Alexin etc) will know how to do this. I personaly dont.
Currently waiting for joints in stencylworks.

zeljko46

  • Posts: 84
[Set velocity to (dir=[[atan2 (y=[y of mouse] - [y-center of self], x=[x of mouse] - [x-center of self]) as degrees] degrees, speed=(any)
This is explained in Abigayls tutorial, not sure which. Maybe you want to find a way to get the x and y of the gun instead y-center of self and x-center of self. Not sure how to do that though.
Play my game: http://www.kongregate.com/games/zeljko46/idle-downloader
Feedback, suggest, and if you want, offer help :)

IAP

  • Posts: 33
The trigonometry for this is a little more complicated then using atan2.

If you know the length and angle of the arm, you can use COS(angle) * LENGTH function to find what is the x value of the bullet, and SIN(angle) * LENGTH to find what is the y value of the bullet.

(Well, I hope I've got it right :P )
Sorry for my English, it's not my first language :)

captaincomic

  • *
  • Posts: 6108
@IAP Yup, you got it right ;)

Here is a screenshot as an example, Fire Direction is the angle (probably "direction of <Self>" in your case) and Offset would be the length of the actor's arm and gun.

Xietao

  • Posts: 725
Create the bullet when mouse is clicked?
Free Time:
Monday, Wednesday, Friday: 13h
Tuesday, Thursday, Saturday, Sunday: 7h
Loving Linux...

Ryzhoff

  • Posts: 54
I had beening doing  it as you told but have incorrect result.
I solved problem but taking cos and sin of atan2(mouse_x-x, mouse_y-y)