Quantcast
Channel: Latest Questions on Unity Answers
Viewing all 171066 articles
Browse latest View live

Rotate UI Image cirlce around self OnMouseclick

$
0
0
Hi good day! I'm having a problem wanting to rotate an Image in the UI that is a circle, the idea is simple that the circle when pressed with the mouse or a touch of the cel you can move it on its own axis following the circular movement of the mouse or finger . But the problem is that when you click on the circle it automatically rotates and then from that given angle it starts spinning based on the mouseposition. v3Pos = target.position; v3Pos = Input.mousePosition - v3Pos; angle = Mathf.Atan2(v3Pos.x, v3Pos.y) * Mathf.Rad2Deg; transform.rotation = Quaternion.AxisAngle(angle,Vector3.forward); Thank you very much to anyone for the contribution to advance!

How to move Animation Clips into Animator Controller?

$
0
0
How can I move my own animation clips into an animation controller so it is a child in the project hierarchy. See pic below. I want them to be children of the controller so it is easier to maintain the project structure and know which clip belongs to which controller e.g. here all the new clips belong to `More Button Controller`. ![folder-hierarchy](https://i.imgur.com/D0sihsz.png) I've tried what is [suggested here](http://answers.unity.com/answers/942554/view.html). It doesn't work with existing clips. It throws an error saying 'Clip already exists'. I've also tried `AssetDatabase.MoveAsset` where new location is `AnimationController/ClipName`. That doesn't work either; it says 'Cannot move.' Is there no way to move existing clips to animator controller?

UI Image Cutout / Masking in spefic areas with sprites

$
0
0
Hi everyone ;) It is my goal to create a tutorial to explain an app. While explaining the functions, I want to set a focus on these by greying out everything else. In my opinion I have three options: 1. Create a "full-screen-sprite" with the specific cutouts. 2. Create multiple images to leave out the specific part 3. Create a black background in black with alpha and cutout peaces to set the focus. I prefer option three and wanted to ask if someone was able to reach something like that or even knows a better solution. Thanks and kind regards, Jannis

AndroidVideoMedia: Error opening extractor: -10000

$
0
0
I have a 360 video player App that uses unity **VideoPlayer** in order to play 20 mintutes 4K videos (that makes a file size of about 4Go). The videos are dragged directly to the VideoPlayer component (without url) and are played using a script included in an asset bundle, which is built for Android platform whitout compression, and loaded to the main App using **AssetBundle.LoadFromFileAsync**. When I try to prepare the video using **VideoPlayer.Prepare** on **Oculus Go** (and other android devices), I get the following Android error (using adb logcat with the Oculus Go plugged to the PC), and the video doesn't play: **07-03 10:41:44.535 12064 12081 I Unity : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45) 07-03 10:41:44.535 12064 12081 I Unity : 07-03 10:41:44.649 12064 12102 W Unity : AndroidVideoMedia: Error opening extractor: -10000 07-03 10:41:44.649 12064 12102 W Unity : 07-03 10:41:44.649 12064 12102 W Unity : (Filename: Line: 471)** I have tried to part the videos into 4 pieces of 5mn by parts, wich gives 4 files of 5mn 4K videos, with about 800M0 to 1Go by video file. I've implemented a play logic that consists in: Preparing the first and the second video. Playing the first video. When the first video reaches the loop point, stop the video in order to free memory, and play the second video while preparing the next one. With this, the first and second videos are successfully prepared and played on Oculus Go, but the above Android error appears when preparing the third video. I use **Unity 2018.3.5f1**, and the encoding settings of my videos are the following: **3840 X 2160 - 30fps - H264 - 25M Bitrate (35M also fires the same error)** If anyone has ever encountered this problem and solved it, please let me know how you managed to solve the issue. Thanks in advance

How to use OnTriggerEnter and OnTriggerExit in multiplayer game

$
0
0
Hi. I'm making a multiplayer game and trying to reduce towers health when player enters in the area. When player enters in, the client will send a message to server, and server will tell both two clients to call the function "ReduceTowerHealth". That's OK. But it will work only for one time. How can I make it continue ? If I send message everytime player stays in the tower area, it would get so much slower.

Rotate multiple axes

$
0
0
Hello, I'm currently trying to do a space sim game, but i have a problem with the rotation. I rotate in the X and Y axis (up/down and left/right) using the mouse with this: rotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity; rotUpDown = Input.GetAxis("Mouse Y") * mouseSensitivity; transform.Rotate(0, rotLeftRight, 0, Space.World); transform.Rotate(-rotUpDown, 0, 0, Space.Self); This way the rotation in the X and Y axis is independent from each other. But when I try to rotate in the Z axis with the Q/E keys it's not. Pressing the keys will also rotate in the X and Y axis. Do you know if it's posible to rotate in 3 axes independently? Thanks!

Customise button using GUI Skin

$
0
0
I have a normal button which i created by right click -> UI -> Button. However, I want to customise the button by using GUI skin. How can I do?

jump and backflip(rotate) like in altos adventure

$
0
0
Like in altos adventure I want to move my player right side automatically so i did using velocity in direction of player. My player Align to curved surface using raycast by finding normal and rotating to that angle. I want to add jump to my player with running velocity how to approach it? And if player holds button it will rotate(backflip) the amount you hold button if you remove you remove held button after rotating half it will align to curved surface slowly. adding force and velocity in upward direction of player is not working properly to curved surfaces. void FixedUpdate() { speed = temp.velocity.magnitude; //angularspeed = temp.angularVelocity.magnitude; if (Input.GetKeyDown(KeyCode.D)) { started = true; } if (started == true) { temp.velocity = transform.right * 10; // temp.AddForce(Vector2.right * 5); } if (Input.GetKeyDown(KeyCode.Space)) { //temp.velocity = transform.up * 10; temp.AddForce(transform.up * 10, ForceMode2D.Impulse); //temp.AddTorque(10); } }

Weird Time.timeScale behavior

$
0
0
I have a bunch of spheres is a scene that all have this drag object script: public class drag : MonoBehaviour { private Vector3 mOffset; private float mZCoord; void OnMouseDown() { mZCoord = Camera.main.WorldToScreenPoint(gameObject.transform.position).z; // Store offset = gameobject world pos - mouse world pos mOffset = gameObject.transform.position - GetMouseAsWorldPoint(); } private Vector3 GetMouseAsWorldPoint() { // Pixel coordinates of mouse (x,y) Vector3 mousePoint = Input.mousePosition; // z coordinate of game object on screen mousePoint.z = mZCoord; // Convert it to world points return Camera.main.ScreenToWorldPoint(mousePoint); } void OnMouseDrag() { transform.position = GetMouseAsWorldPoint() + mOffset; Debug.Log(this.transform.position); } } This script works great until time.timescale is set to 0 via a UI button. while the game is paused, the object can be dragged once normally, but then to move the object again, you must move your mouse to the original location before the drag instead of the actual position. Steps to re-create: 1.Make a new 2d game 2.Make a sphere, attach the above script 3.Set time scale to 0 4.Try and drag the sphere twice I can send my project if necessary

Is it possible to create an Ios game with unity3d on a windows PC?,Is it possible to create ios app with windows computer on unity?

$
0
0
I think that only with apple computer you can create Iphone/Ios games and android apps too. And with windows computer you can only create games for android. Is it possible to create with unity an Ios app by windows computer? ,I think that only with apple computer you can create an iphone app and android apps too. And with windows computer you can only create android apps. But how about unity can you create with unity3d an ios app with windows PC?

How to use Unity with Laravel

$
0
0
I want to use Laravel for backend so Unity is frontend, how to connect unity to laravel. is it possible to do this? any ideas?

Jumping Problem

$
0
0
I am making a simple game and i need my player to jump. They way i want to do it i get the error: Operator '&&' cannot be applied to operands of type 'bool' and 'float'. Here is my script: public class Jump : MonoBehaviour { public Rigidbody rb; public float UpForce = 2000f; public float jumpCount; void FixedUpdate() { if (Input.GetKey("w") && jumpCount = 0) { rb.AddForce(0, UpForce * Time.deltaTime, 0, ForceMode.Impulse); jumpCount = 1f; } } void OnCollisionEnter(Collision collisionInfo) { if (collisionInfo.collider.tag == "Floor") { jumpCount = 0f; } }

Automatically set best quality settings?

$
0
0
So you know how in games now they automatically detect your hardware and automatically set the right graphic settings for you? That's what I'm trying to do because my game is very high quality and takes ages to load on lower end systems. They can be changed in game but I want it to also automatically set it. How would go about implementing this?

how do I change one object for another when the object is clicked?

$
0
0
here is the script i am using at the minute to change the material of a sphere so it changes colour when the mouse is over it, instead what i am trying to do is change the object from a sphere to a building when the sphere is clicked, i did the colour thing to make sure the script worked and now i cant figure out how to change the sphere to a building instead, the idea behind this is the user/player is clicking on a push pin to show the building connected with its position on a globe. using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Selectionmanager : MonoBehaviour { [SerializeField] private string selectableTag = "Selectable"; [SerializeField] private Material highlightMaterial; [SerializeField] private Material defaultMaterial; private Transform _selection; private void Update() { if (_selection != null) { var selectionRenderer = _selection.GetComponent(); selectionRenderer.material = defaultMaterial; _selection = null; } var ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit)) { var selection = hit.transform; var selectionRenderer = selection.GetComponent(); if (selectionRenderer != null) { selectionRenderer.material = highlightMaterial; } _selection = selection; } } } i'm not crazy bothered by it being well optimised at this point i just want something functional. thank you in advance!

Why Request in IOS return sucess false( unknown error)?

$
0
0
I make a request to the server asking for login, which takes my mail, password and a firebase token, all of these are sent correctly, however, the response data returns with a false and an unkwown error, this happens only on Ios Already checked the petition on Insomnia, read various of the jsons returned and reduced the problem to Ios platform, checked the pod file to see if I missed references, but it all seems right void generatePOSTRequest(string slug, string request, System.Action callback) { WWW www; Dictionary postHeader = new Dictionary(); postHeader.Add("Method", "POST"); postHeader.Add("Content-Type", "application/json"); byte[] formData = System.Text.Encoding.UTF8.GetBytes(request); www = new WWW(apiURL + slug, formData,postHeader); StartCoroutine(WaitForRequest(www,callback)); } //slug is server/api/login //request is a json with a mail, a password and the firebase token

Enemy AI using pathfinding to avoid obstacles

$
0
0
Hello, I am trying to make a TowerDefense game and I want my enemies to avoid the obstacles in front of them and to search for the path to reach their Endpoint. The player will be able to block their way and they need to search for another path. How am I able to make this kind of movement and pathfinding? Can you guys give me some hints? Ive been trying to follow a few tutorials about A* algorith but I am not able to implement the automatically movement on my enemies. Thank you in advance!

Rotate canvas

$
0
0
So pretty much I want to rotate a canvas, so it looks at my player. The thing is, I only want it to rotate in the y-axis when looking at it, and I tried with a look at but it didn't work. Currently, I have no code because it just wasn't working even when freezing the rotation so I have no idea, so sorry about that. Thanks in advance.

ANDROID SDK is not working / is missing

$
0
0
Hello everyone. First of all, I am very sorry that my English is not very good. I'm having a problem to export from Unity to Android. I install Unity and add the necessary JDK and SDK for the app to work on Android. But when I select "Build" in "Build and settings" I get the error of the image. I have installed the latest version of everything and have tried using the default SDK and also the Android Studio SDK. Nothing works and I'm desperate. If anyone knows the solution, I would be very grateful. (The image is in a Tweet because the server didn´t let me tu upload it) Image: https://pbs.twimg.com/media/D-j-jKtWsAEemxl.jpg

2D animation problems!!!

$
0
0
Hello! I am pretty new to coding, so this might look like an easy fix to you, but i can't figure out myself! The problem i have is: All of my animations work perfectly fine, but when i jump and land on the ground, he keeps doing the jump animation. When he lands and i press a button afterwards, he goes back to his Idle animation. What i want is that when he lands on the ground i want him to go back to his Idle animation immediatly. I appriciate all the help i can get! (But please try to keep it as easy to understand as possible. Again, i am pretty new!) My c# script: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Character : MonoBehaviour { Rigidbody2D rb; private Animator anim; public float speed; private float moveInput; private bool isGrounded; public Transform feetpos; public float checkradius; public LayerMask WhatisGround; public float Jumpforce; AudioSource audioSource; public AudioClip ActualJump2D; // Use this for initialization void Start() { anim = GetComponent(); rb = GetComponent(); audioSource = GetComponent(); } // Update is called once per frame void Update() { if (moveInput > 0) { transform.eulerAngles = new Vector3(0, 0, 0); } else if (moveInput < 0) { transform.eulerAngles = new Vector3(0, -180, 0); } if (moveInput == 0) { anim.SetBool("isRunning", false); } else { anim.SetBool("isRunning", true); } isGrounded = Physics2D.OverlapCircle(feetpos.position, checkradius, WhatisGround); if (isGrounded == true && Input.GetKeyDown(KeyCode.Space)) { anim.SetBool("isJumping", true); rb.velocity = Vector2.up * Jumpforce; audioSource.PlayOneShot(ActualJump2D, 0.2F); } if (rb.velocity.y == 0) { anim.SetBool("isJumping", false); } } void FixedUpdate() { moveInput = Input.GetAxisRaw("Horizontal"); rb.velocity = new Vector2(moveInput * speed, rb.velocity.y); } void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.name.Equals("MovingSlab11")) this.transform.parent = col.transform; } void OnCollisionExit2D(Collision2D col) { if (col.gameObject.name.Equals("MovingSlab11")) this.transform.parent = null; } }

Planning Text Scroll with Unity UI

$
0
0
I created a textbox by following Brackeys tutorial, and it uses text that appears letter by letter. When executed, the text will scroll out to the edge of the UI text area, go outside the edges, then correct itself. I was wondering if there was a way to find if the words will go outside the text area, then type the letters out. I don't know where to go with this so any help would be appreciated! Link to Brackeys tutorial: [link text][1] [1]: https://www.youtube.com/watch?v=_nRzoTzeyxU
Viewing all 171066 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>