Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Mobile Input

Discussion in 'Input System' started by coding_storm, Apr 6, 2021.

  1. coding_storm

    coding_storm

    Joined:
    Mar 26, 2021
    Posts:
    34
    Hi guys ,I needed help in creating a grenade throw and punching function ,can someone please share a reference or a code to do this.
     
  2. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    927
    You should really watch some tutorial series before making a game completely on your own
     
  3. coding_storm

    coding_storm

    Joined:
    Mar 26, 2021
    Posts:
    34
    I know but there is no tutorial on other things except the touch control which I did from brackeys. Can you suggest some if you know.
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I don't have much experience with mobile touch controls specifically, but on grenade throwing vs punching I'd expect you'd want to design them totally differently. With grenade throwing you'd likely instantiate a grenade prefab, then either move its transform manually or if you're using physics you'd add a force. As far as the explosion of the grenade, you'd do that all with scripts on the grenade instead of the character. I'm not clear if you're looking to do some kind of touch slide to adjust throw force and direction, or just a button you press to throw the grenade forward.

    A punch mechanic though would usually involve a character animation and some collider or raycast from the character's hand to detect an impact on another object.

    You should be able to find generic object movement, prefab instantiation, and collision detection tutorials which cover most of the above. Don't be focused on finding a specific mobile grenade throwing and punching tutorial all in one, that likely does not exist.

    I suggest working through this stuff a little more so you can come with a very specific question. You're more likely to get a helpful answer the more specific and detailed the question, as long as it isn't so obscure that no one else has done it before. Good luck
     
    coding_storm likes this.
  5. coding_storm

    coding_storm

    Joined:
    Mar 26, 2021
    Posts:
    34
    Yes thanks for such a good reply ,I understood it ,I will have a button to throw the grenade ahead and the punching part also is well cleared but the thing is that I cannot understand what to write in the script so that it throws the grenade when the button is clicked and same for punching