Drop In Drop Out System with Input? - unity3d

I'm trying to code a drop in drop out system with input. Basically i have 2 sprites and im trying to swap between controlling each one. Right now I have a button i press and it switches which sprite is active however it does not let me show the animations for the other sprite and i can't control it. It also makes the other sprite that i'm not swapped to go off screen. I need both sprites to stay on screen and be able to press a button and and be able to control the other with the same input. If anyone could help me it would be much appreciated i couldn't find anything about it on google considering this is a very specific problem.

Related

The tilemap covers the floating text UNITY 2D

So I want to display a floating text everytime the player opens a chest, that indicates how many coins you earned. I created the level using tilemaps. The problem arises when I created the floating text, basically it's covered by the tilemap, because if I move it out of the level I can see it, otherwise not. I tried fixing this problem by using layers, but I can't manage to make it work. Does anyone know how to help me?
As you can see by the foto the outline of the text is visible, but in play mode you can't see it.
You should probably use the order in layer in the tilemap renderer and set it to a negative value.Im sorry if it doesnt work I am new to unity.

In unity how to make in-game menu?

I'm making a Unity2D mobile game but I'm stuck on making a menu. I want the in-game menu and if the player touches the screen or clicks the screen, the game will start and the menu will be have store, options but I don't know how to do it. I tried to do the same scene but this time when it goes to the next level, the menu disappears. I searched on the internet but couldn't find it. Thanks.
You should first create a UIManager script for yourself.
In this script, you must define 2D elements such as Text, Canvas, Panel and provide their functionality.
Then you can control these functions in your main manager (GameManager).
To put it simply, it takes almost a video tutorial to explain it.
Because this is not a simple code error question, man.

Moving mouse cursor with gamepad question

So I can create a gameobject that I can move around like a cursor with my xbox controller, however when it comes to pressing buttons I have 1 issue.
It seems there is no way to set the actual mouse cursor position without importing user32.dll and even that solution will only be a windows solution. https://answers.unity.com/questions/330661/setting-the-mouse-position-to-specific-coordinates.html
The reason I want to move the actual mouse cursor as well as my gameobject representing a cursor, is that I still want to be able to click buttons, and when I call Input.GetMouseButtonDown(0); it will click the button at the point where the actual mouse cursor is, and if the actual mouse cursor isnt moving with us its not gonna work.
Also I dont need a custom mouse cursor, if the xbox controller could move the mouse cursor directly thats fine too.
Any advice appreciated.
There is no other way to set the mouse position maybe if you needed to have a solution for mac as well you can find it here at the bottom.
also making a custom cursor is a better solution cause it will be cross platform and you could make a custom mouse down event for it so i don't see why you wouldn't
and if you are sure you need the actual mouse to move you only have the first solution
and moving the mouse with xbox controller by using a software is only gonna work on your pc and those softwares are probably using the first solution

how to reference an "armature action" of a bow using code?

I'm trying to make a bow and arrow game. I downloaded a bow that has an animation(?) on it where the string is pulled back.
See:
I want to make a script that triggers that animation (shown on bottom-right of my gif) when Player left clicks. But I don't know how to reference the animation.
Is it something like _anim = GetComponent<Animator>(); and then animation.Play? I cannot tell what the name of the animation even is to do this.
Further.. it would be awesome to be able to control the animation's length depending on how long the user has held down the button, rather than playing it in full even if user only taps left click. I'm not sure how that would be achieved?
Ok, the question seems short but the solution will be long and you need to do a bit of learning. So, let's go through your question step by step.
I downloaded a bow that has an animation(?)
Yes, it is a 3D bow model with an animation in it.
I want to make a script that triggers that animation (shown on
bottom-right of my gif) when Player left clicks. But I don't know
how to reference the animation.
In order to trigger that animation, you need an Animator Controller attached to the bow model instance. Then you can click that Animator Controller to open its panel. After opening the panel, you can simply drag and drop your animation there. When you first drop your animation, it will be the default animation state. However, if you don't want to trigger the animation immediately, I would suggest you to create an empty state and make a transition to the bow animation.
Is it something like _anim = GetComponent(); and then
animation.Play?
More or less like this, but you should check the documentation for better understanding, this documentation explains it well and has a really good example for your use case.
I cannot tell what the name of the animation even is to do this.
Once you drag and drop the animation to the panel, you will see the name of the animation to use in the script.
Further.. it would be awesome to be able to control the animation's
length depending on how long the user has held down the button,
rather than playing it in full even if user only taps left click.
I'm not sure how that would be achieved?
There are many ways to play with animations, for example, you can set an animation parameter to stay in the animation state. Furthermore, you can also disable the Has Exit Time value from the transition to make it stop the animation immediately after the user stops holding the button.
Overall, when it comes to animations, Unity is quite powerful and my suggestion would be read the documentation and watch a couple of tutorials.
Hope this helps.

Scene screen is stuck

I'm new to Unity and I'm trying to make my own game (or at least learn to). I have a problem in the scene screen.
The scene screen is stuck on this mode and I don't know how to bring it back to the original camera view(hope you guys understand what I'm meaning), Tried to search how to do it but couldn't specified what I want, please help.
The Canvas when in Overlay mode turns out to be a giant object compared with normal scale.
You are just too far from your objects, to return to normal you can navigate manually right clicking Scene window and moving with WASD and QE.
Another workaround is that you use the FIND shortcut like following:
Click the object you want to find on Hierarchy window
Move your cursor to Scene window without clicking
Press F on your keyboard
If perforned correctly the Scene camera will find that object and you will be right back to where you were.