Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Touch and mouse input Unity

A topic by TheWrongJohn created May 27, 2023 Views: 275 Replies: 4
Viewing posts 1 to 4
Submitted (1 edit)

Hello, I have submitted my ‘game’ but didn’t manage to set up the controls in the way I wanted. There are a couple of days left though and maybe I can sort it out in time.

Anyway, does anyone know how you can set up touch (taps and position) and mouse click (click and position) so that the game can be played on computers (with a mouse) and on mobile devices (with touch) for WebGL builds (to be played in the browser)?

 Currently, my game is working as a WebGL build on mobile devices with touch, but not on computers with mouse.


I am using Unity with C#

Submitted

 you can use raycast if you want set another position for your player or instantiate preafabs, or standart metod 

private void OnMouseEnter(){if(Input.GetMouseButton())}.(work to both systems if you going to do two different buildings)

Recomend you look Unity Junior Programmer way

Submitted

Thank you for the ideas! I'll let you know if I get things fixed. I had a look at the Unity Junior Programmer Pathway, looks very interesting/useful, thanks!

Submitted

Update: managed to make my 'game' 'playable' with mouse clicks using a button linked to a function. Not ideal but the quick and dirty fix I needed. Now for the next game jam! Good luck everyone!

Submitted

What is the name of your game?