How to see which mouse button was pressed (Unity Input System)

I have switched my game to use the new Unity Input System, and I want to know which mouse button was pressed when an action is called.

Here’s how it’s set up: Input System

Whenever one of these three mouse buttons are pressed, the MouseButtonClicked action will fire. I want to somehow know which one of these buttons was pressed from this single action, rather than making 3 seperate actions for 3 seperate mouse buttons.

I have tried reading the values from InputAction.CallbackContext context but I can’t seem to get a proper value from the mouse button which was pressed.

How can I do this?

When or why would someone use a programming language (Swift, Java, C++, Rust etc…) over an engine like Unity?

Everytime I’ve read about people asking whether they should write their game in C++ or Unity, Unity is usually the default answer, unless they want to go through the hassle of creating an engine by themselves when Unity already does everything for you. If that’s the case is there ever a case where writing a game in C++, Java, Rust etc… is better than using Unity? If so what are these cases?

Snooker/Pool AI Predicting end location of cue ball Unity

I’m trying to implement a pool/snooker game. I figured the best way to implement the ball movement/potting mechanics is to use the physics simulation, apply an impulse to strike the cue ball and let the simulation deal with the rest. This seems straight forward enough but I have no idea where to start with the AI. For the AI to be anywhere near convincing it will need to consider the position of where the white ball will end up when planning what shot to play. Can anyone offer any advice on how I can predict where the white will end up when working with the physics engine? Or does this requirement make using physics a really bad idea?

Load new scene unity?

How do I load the next scene in unity when my player hits a 2d sprite?

This is my current code –

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;  public class Loader : MonoBehaviour {     public Animator sceneChange;     private Coroutine _loadInProgress;       void OnTriggerEnter2D(Collider2D other)     {         if (other.CompareTag("End"))          {             Debug.Log("END");             LoadNextLevel();         }                     }      public void LoadNextLevel()     {         if (_loadInProgress == null) {             int nextLevel = SceneManager.GetActiveScene().buildIndex + 1;             _loadInProgress = StartCoroutine(LoadLevel(nextLevel));         }     }      IEnumerator LoadLevel(int LevelIndex)     {         sceneChange.SetTrigger("Start");         yield return new WaitForSeconds(1);         SceneManager.LoadSceneAsync(LevelIndex);         _loadInProgress = null;     } } 

Where do I put this code so that when I collide I load the next level?

Unity animation moves a game object. Should I create all my animations again from the scratch?

Unity animation moves a game object. Should I create all my animations again from the scratch? Or how can I fix the issue?

I recorded approximately 15 animations in Unity. Now I try to animate in place and simultaneously use the physics engine of Unity to move game object. But I found out that the animations actually change position of my game object.

I tried to follow the advice from here:

I came across with the same problem, and I fixed it with parent game object. But, there is a small trick: Create a new game object inside your problematic game object, the new game object gets the parent (0,0,0,) coordinates and this will be the origin coordinates. Then, put the old game object as a child to the new one and make all the positions as you like. Try a few times and you will get there.

But the result was just the same. The game object still changes its position during animation. So, now I am afraid that I will have to start everything over again and do animations once more. Last time it took me two weeks to complete all the animations. So, I am hoping to find another solution, which would help to fix my problem without remaking all the animations.

enter image description here

Difference in light between Unity 5.5.2f1 and Unity 2019

The lighting is different between Unity 5.5.2f1 and Unity 2019. Please see the attached image.enter image description here

I dislike the way the lighting is done in the 2019 version. Both verions are installed out of the box, without any additions.

What do I need to change / set up inside Unity 2019, in order to have the exact lighting as in 5.5.2f1 version?

Unity 3D – Why does my button need to be clicked twice to work?

My goal is to go back and forth between a series of animations by clicking left and right arrow UI buttons. I wrote this C# script and the "next" button (which executes AddInt() on click) works as intended, however the "previous" button (which calls ReduceInt() on click), needs to be clicked twice to work. Is this a glitch or is something wrong with my code?

public class update_animator_parameter_int : MonoBehaviour {     Animator gameobject_animator;     public string int_parameter;     public int max_int;     public int current_int=0;      void Start(){         gameobject_animator = GetComponent<Animator>();}      public void AddInt(){           current_int++;           if (current_int > max_int){current_int = 0;}           gameobject_animator.SetInteger(int_parameter, current_int);}       public void ReduceInt(){           current_int--;           if (current_int < 0){current_int = max_int;}           gameobject_animator.SetInteger(int_parameter, current_int);} } 

I’m having trouble with SetBool and animations on Unity. Can anyone help me?

I’m trying to get a Skeleton Model to go from its walking animation to its idle animation using a bool that checks for input. Currently, in-game, the skeleton doesn’t leave it’s walking animation and stays in it even when not walking. I’ve posted my code below. I’m kind of stumped so if anyone can give me some guidance it’d be greatly appreciated.

public class SkeletonMove : MonoBehaviour {  private float velocity = 5f;  public bool _isWalking = false;  Vector2 input;  void Update()     {         GetInput();          if (Mathf.Abs(input.x) < 1 && Mathf.Abs(input.y) < 1) return;          // CalculatedDirection();         Rotate();         Move();     }  void GetInput()     {         input.x = Input.GetAxisRaw("Horizontal");         input.y = Input.GetAxisRaw("Vertical");     }  void Move()     {         _controller.Move(transform.forward * velocity * Time.deltaTime);         _anim.SetBool("Walking", _isWalking);           if (input.x != 0 || input.y != 0)         {             _isWalking = true;         }          if (input.x == 0 && input.y == 0)         {             _isWalking = false;         }            //transform.position += transform.forward * velocity * Time.deltaTime;     } 

Unity – Save and load “Snapshots” of game for debugging?

I’m relatively new to Unity debugging, and I’ve got an issue that happens every so often about 2 minutes into playing through a scene. If I can do the following, it would save me a lot of time debugging:

  1. Pause the scene
  2. Save the snapshot
  3. Modify some code
  4. Play the snapshot saved in step 2
  5. Repeat 3-4

Is this at all possible with Unity, or should I just modify my code to running "closer" to the point I’m trying to debug?

Unity project not communicating with my iPhone 11?

Connecting to my iPhone 11 with a cool FaceTracking project called FaceCapOSCReceiverExample https://github.com/hizzlehoff/FaceCapOSCReceiverExample works excellent on my laptop, but not on my PC (Windows 10 and ubuntu dual boot. I am using Windows 10 for this project).

On my PC the only AntiVirus/firewall I have is Windows Defender. On the Inbound and Outbound rules, I deleted everything that had the word ‘Unity’ in it. I then added custom rules, allowing everything, for the program paths of Unity Hub and all Unity Editor installations.

But no luck. The program won’t communicate with my iPhone.

I even tried turning the firewall completely off and re-launching Unity as admin. No luck.

I then manually installed the latest drivers for my network adapters (I have both "Killer E2400 Gigabit Ethernet Controller" and "Qualcomm QCA9377 802.11ac Wireless Adapter" in Device Manager). No luck!

I also connected my PC to a personal hotspot from my iPhone. This was a tethered (purely USB) connection that I had running. But, while the tethered Internet worked great on my PC, it still didn’t make the Unity project communicate with my iPhone! ;O;

I then added a rule to my firewall where I created a TCP port number 60001 and set it so private and public could connect. (I’m very newbie about ports) Then I entered that as the Port number within the Unity project. Still no connection was made…

I have no idea what to try from here! Like I said, it works great on my laptop, but my laptop is too dang laggy to use with it, so I would really love to get it running on my PC.