Unity - how to make a player controller with gyroscope and accelerometer

Поділитися
Вставка
  • Опубліковано 21 лис 2024

КОМЕНТАРІ • 51

  • @SelaMalka
    @SelaMalka 9 місяців тому +1

    Thank you!!

    • @lurple_
      @lurple_  9 місяців тому

      You're welcome :)

  • @gonzatoto
    @gonzatoto 2 роки тому +4

    The best tutorial of this topic. Congratulations, and thanks! Like and suscribed

    • @lurple_
      @lurple_  2 роки тому +1

      I'm glad I could be of help. me myself have been stuck on this same problem for months and after a lot of searching and looking at people smarter then me on ton of forums I found a way to finally achieve a good result.

    • @lilhappy2456
      @lilhappy2456 2 роки тому

      Epic

    • @kum8387
      @kum8387 2 роки тому

      0o0

  • @ianfield17
    @ianfield17 Рік тому +2

    Does anyone have the issue of the player sliding for no apparent reason when holding your phone still?

    • @lurple_
      @lurple_  Рік тому +1

      The issue might be that the controls are pretty sensitive, meaning that you have to make sure that the phone is perfectly in one place for your character to stand still, basically way the rotation works is depending on way your phone is facing it will choose that direction as the original rotation, so if you place your phone let's say on your table it should just look in one direction and don't slide since no tilting is being done by you with the phone. I hope this helped you in any way and thank you for the comment

    • @ianfield17
      @ianfield17 Рік тому

      @@lurple_ thanks! I'm thinking I'll just put a minimum force value that's greater than the sliding speed so that it only moves when I move faster than that. Maybe that will stop it

    • @lurple_
      @lurple_  Рік тому +1

      @@ianfield17 good idea I like a game developer that thinks of he's own unique solution to a problem cause I relate whenever I come across a bug I always choose the most barbaric solution but it still feels good to solve a problem you've been stuck on for a while, anyways I wish you the best of luck on your game dev journey and I hope my tutorial was more helpful than confusing :)

    • @ianfield17
      @ianfield17 Рік тому +1

      @@lurple_ thanks a lot! I appreciate it.

  • @loudogrestudios
    @loudogrestudios 2 роки тому +2

    Bruh, you`re soooo underrated!!! Subscribed instantly!!!!

    • @lurple_
      @lurple_  2 роки тому

      Aww I'm glad I could help this means a lot to me thanks for the sub I hope I can help more in the future :)

    • @loudogrestudios
      @loudogrestudios 2 роки тому

      @@lurple_ you just save my gamedev attempt rn. I was stuck in the quaternion and you helped me a lot!! Thanks again bro 💪💪💪

    • @lurple_
      @lurple_  2 роки тому +1

      Nah no need to thank me man I'm really happy I could help actually the whole reason why I made the tutorial is since I was stuck on I'm pretty sure similar issue as you so yeah I'm really happy I could have someone that's stuck on same thing I was struggling with not that long ago and thank you again really comments like yours really motivate me in so many ways thank you man

  • @htasul
    @htasul Рік тому +1

    Perfect! Exactly what I was after - thank you

    • @lurple_
      @lurple_  Рік тому +1

      You're very welcome my good sir

  • @haliluzdil
    @haliluzdil 2 роки тому +1

    This is best tutorial.. You are prof. You are best

    • @lurple_
      @lurple_  2 роки тому

      Glad I could help :)

  • @1negroup841
    @1negroup841 2 роки тому +3

    Here is the Script without the accelerometer - paste.myst.rs/j7rol335 if you want the accelerometer just uncomment the code under movement in Update.

    • @lurple_
      @lurple_  2 роки тому

      Thanks for that I'm sure it will save some time for the viewers :)

  • @MontageHDr
    @MontageHDr 19 днів тому +1

    Cool work!!!

    • @lurple_
      @lurple_  19 днів тому

      Thanks captain.

  • @DaMu24
    @DaMu24 Рік тому +1

    This is an interesting tutorial, but unfortunately I've been having problems compiling the Android executable using any LTS version of Unity, something to do with Grandel or Java errors. The gyroscope code is still useful.

    • @lurple_
      @lurple_  Рік тому

      I'm happy as long as I can help in any way I would recommend using officially supported versions of unity

  • @noizu6022
    @noizu6022 4 місяці тому +1

    Hi can i ask did you make the graphics of the game i want that game style too

    • @lurple_
      @lurple_  4 місяці тому +1

      Hey thanks for the comment, the game style is achieved through a shader which takes in a color palette, I actually have a video about achieving this exact style right here: ua-cam.com/video/l_riMKs_uZw/v-deo.htmlsi=lwiHCrWPa9xfhzFx
      The video is silent and not very good I apologize for that but it showcases fully how to achieve this type of look, I hope it helps you achieve this look

    • @noizu6022
      @noizu6022 4 місяці тому +1

      @@lurple_ thank you so muchhhh

    • @noizu6022
      @noizu6022 4 місяці тому +1

      @@lurple_ does it work to version 2023?

    • @lurple_
      @lurple_  4 місяці тому +1

      @@noizu6022 yes I'm pretty certain it does, in the video I'm showcasing it on a 2020 version though.

  • @lizardspherestudio
    @lizardspherestudio Рік тому +1

    Help. I read that Input.acceleration only uses accelerometer but if i disable gyro, Inut.acceleration wont work so they might work together depending on the device or something like that?

    • @lurple_
      @lurple_  Рік тому +1

      As long as the device you're using to test ur game has access to both or at least one of those accessibilities that specific one will work and the other one of course won't same scenario takes place if you disable one of them only the other will work I don't think disabling one of them interferes with the other's performance I hope this could be of help :)

  • @S111A111S
    @S111A111S 2 роки тому +1

    How to receive accelerometer and gyroscope data from gamepad?

    • @lurple_
      @lurple_  2 роки тому

      I haven't really ventured into developing a controller game but if I'm correct the same code might work with a controller same as it does when paired with a phone.

  • @tulio_dev4380
    @tulio_dev4380 Рік тому +1

    @Lurple I followed all steps of tutorial, but gameObject is not rotating. What did I messed up?

    • @lurple_
      @lurple_  Рік тому +1

      Make sure you add a character controller and also make sure that the player controller script is word for word correct if not even the slightest mistakes can break it.
      You can find the full code here: paste.myst.rs/j7rol335 ;)

  • @dimasarifw
    @dimasarifw 2 роки тому +1

    thanks!!!!!

  • @leflob938
    @leflob938 2 роки тому +1

    Do u have any Idea how i could do a similar game but with WebGL? Because I want to run the game on a PC and use the Smartphones Gyro just as a joystick. We already get the gyro Data from our website into Unity but we oviously can´t use Input.gyro.Enabled bacause it is not an android build.

    • @lurple_
      @lurple_  2 роки тому +1

      This is really interesting problem/idea you've proposed I haven't really got into WebGL but I did have a similar idea a long time ago it went something like this: it was an idea for a mobile game like 5 people would download the game and open it and then one person would host a game and the other 4 would join just like a normal online game but what's different here is whoever hosts the game works as the game screen and everyone who joined their mobile devices only have one purpose and that is to be used as a controller so yeah I'm sorry I couldn't really help but I would happily help you with the project if you would like that feel free to give me your discord name and the 4 letter digit code thanks :)

    • @leflob938
      @leflob938 2 роки тому

      @@lurple_ I would be totaly down for that, my Name is Leflob and code is 7683
      thanks in advance :)

  • @osamanamur633
    @osamanamur633 2 роки тому +1

    wow this is great

    • @lurple_
      @lurple_  2 роки тому

      Thank you this means a lot :)

  • @tompontejos6554
    @tompontejos6554 2 роки тому

    how to stop the auto movement and change the movement depends on when the camera is moving forward or backward (actual movement of user using phone )

    • @lurple_
      @lurple_  2 роки тому

      That was actually my first intend when I was writing the code to move the player according to the phones precise rotation and the force that is used on the phone in real life aka detecting my actual movements in person while holding the phone but I couldn't get this system to work that's why I use an accelerometer for the phone it seemed like a good replacement for what I wanted to achieve but while I was doing my research I came across few ways of doing what you want achieve to put you on the right track I recommend using GPS coordinates to move the player this will helps you if you're using a broader playing field like if you want to detect somewhat precise movements of the phone over a long distance like pokemon go for example

    • @tompontejos6554
      @tompontejos6554 2 роки тому

      @@lurple_ thanks sir but I dont plan to use GPS, do you have any other idea on how to move the camera when actual moving. like putting a script in a camera and make it work

    • @lurple_
      @lurple_  2 роки тому

      @@tompontejos6554 there is a plugin for unity that does the exact thing you want to achieve I'm pretty sure it's open source I found it later on in my development if I had founded the plugin sooner I might have not written this script I'll try to look for the plugin I'm not sure exactly what it was called but when I find it I'll make sure to let you know

    • @dssanjaya979
      @dssanjaya979 Рік тому

      @@lurple_ hello, did you find that plugin?? My team is working on real-time motion tracking of the user so it would be helpful for us if u share some info. Thank you in advance 😊

    • @lurple_
      @lurple_  Рік тому

      @@dssanjaya979 I'm sorry to say I couldn't track it down I remember that it was a plugin developed by Microsoft I randomly came up on it one day but I couldn't find it again I hope you can find it and thanks for the comment I'm happy if my tutorial could help in any way :)

  • @leflob938
    @leflob938 2 роки тому +1

    I think you hide your email so i gave u my DC credentials as an answer to ur comment, feel free to reach out any time ;)