How do I make a character shoot in the direction I drag him



  • So I have a game where what I want is to be able to have a character that's shoots in the direction I drag him. When I drag him at the moment in any direction he shoots from the top, bottom, left and right at the same time. How do I make it so that when I drag him up he shoots up and vice verse



  • @miniwolfen Does the character move when you drag it, or it stands still but dragging in a direction makes him shoot? Is it using the drag and drop behaviour? I would do it differently depending on what exactly is happening.



  • @aidan-oxley it moves and shoots when I drag it


  • Admin

    We need more information than that to really help you come up with a solution. There are many different ways of doing this and a lot depends on how your game is currently created and what you want the outcome to be.

    From your first post we get that it shoots when you drag. But answering each of aidians questions will really help get you the best answer.

    Try to be as detailed as possible since we are not seeing your project or in your brain to know what you’re trying to accomplish :).



  • @miniwolfen Ok, made an example project, involves a bit trigonometry, here's a link: http://bit.ly/2BeWmyb
    Object just shoots every 0.5 seconds, once you start dragging it, it starts shooting in the direction it is moving. The object has to be physics for this one to work.

    I'm not sure whether it will work or not for you since I made it in the beta version, but you might be able to look at the behaviours inside the red square (the label does nothing useful at all). If you can't, tell me and I'll screenshot it for you.

    If you want, I can modify it to also make the bullet shoot faster depending on how fast you are moving. But this also depends on how fast your bullet is, if it's really fast then there's not much point doing it if the player is quite slow in comparison.



  • @aidan-oxley thanks