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

need help with in-air movement

$
0
0
Basically, Im trying to implement a full force based movement controller, but i cant figure out how to control the player in the air without either cancelling all current momentum, or allowing the player to speed up to much midair. Here is my current code, if anyone has any ideas how to fix this it could be much appreciated. if (ifGrounded()) { Vector3 targetVelocity = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); targetVelocity = slopedMovementController.transform.TransformDirection(targetVelocity); targetVelocity *= speed; Vector3 velocity = rb.velocity; Vector3 velocityChange = (targetVelocity - velocity); velocityChange.x = Mathf.Clamp(velocityChange.x, -maxVelocityChange, maxVelocityChange); velocityChange.z = Mathf.Clamp(velocityChange.z, -maxVelocityChange, maxVelocityChange); velocityChange.y = 0; rb.AddForce(velocityChange, ForceMode.VelocityChange); }

When I am switching between the scenes, they reset. Is there a way to stop scenes from resetting to default on load?

$
0
0
In my game, I have my player that collects points so that it can upgrade itself. It would need its own scene for the player to upgrade in. However, I want the player to return to the game exactly where they left off in a different scene. When I am switching between the scenes, they reset. Is there a way to stop scenes from resetting to default on load?

Animations not importing into Unity from Blender

$
0
0
So on this 3D platformer tutorial I was doing I managed to figure out the floating issues but now I have another problem. For some reason when I import the model from Blender only like two of the animations seem to import in at a time. As an example the player model I was using has animations for Idle, running, walking, attacking, projecting, and rolling. However upon importing the model into Unity only one of the idle animations and the jump animation are present. even though I had import animations clearly checked as well as all actions checked in the export settings for blender. Do you think there is something I missed in Blender?

Port particles to center of UI element

$
0
0
Hi guys :) First of, yes I used the search, but after 2 hours I couldn't find a working solution. So I have these energy particles (transforms with particle systems), that should start in Circles on the UI and then move to positions on the screens. Canvas is in Overlay, Camera orthographic. I am still failing at just getting them to the right positions at start-up (done in script as it should be scaleable with resolution). Now, I am f.e. trying out: private void Start() { transform.position = Camera.main.ScreenToWorldPoint(EnergyCircle.GetComponent().anchoredPosition); } But whatever I do, the particle Transform just appears elsewhere. Here a screenshot, nested hierarchy ![alt text][1] ---------- Please help. [1]: /storage/temp/145066-send.jpg

Ridiculously Simple Problem That I Cannot Solve - Please Help

$
0
0
This is giving me an Ulcer. All I'm attempting to do is when the player collects this GameObject (idol) the door over there gets destroyed (IdolDoor). I've got to be missing something incredibly simple: idol script: public class Idol : MonoBehaviour { IdolDoor idolDoor; // Use this for initialization void Start () { idolDoor = GetComponent(); } void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.name == "Player") { Destroy(gameObject); idolDoor.DestroyMyself(); SendMessage("DestroyMyself"); } } } IdolDoor script: public class IdolDoor : MonoBehaviour { public void DestroyMyself() { Destroy(gameObject); gameObject.SetActive(false); } } Both scripts are attached to their respective gameobjects. Upon the player colliding with the idol it disappears, but the door remains. If anyone has any clue what this could be please let me know. Thanks!

Hololens Dev: UWPuilding Failling due to missing HolographicAppRemoting.dll

$
0
0
Hey Guys, Two questions: 1. The Holographic emulator will connect to the IP of the Hololens, but won't properly when playing the scene 2. The project can be built, but when trying to deploy it it pops up an error stating that HolographicAppRemoting.dll in the Plugin/x86 folder cannot be found. I can find the corresponding file in the x64 folder but it won't work when copy/pasting it into the x86 folder, it will only open a window view in the Hololens. I'm using Unity 2019.2.2f and MRTK v2.0.0 and trying to run a Rossharp project on it. (Github link of the Rossharp [link Rossharp](https://github.com/dwhit/ros-sharp) Anybody having the same error or has an idea on how to solve this? Thanks allot Dshapir

2019.2.2 Unity remote 5 not working

$
0
0
I've sunk hours into this problem and nothing has changed. I'm building on the android platform, I have all the android tools installed in external tools (the JDK, SDK, NDK, all of them), I also have any android device selected in the editor in project settings. So when all that didn't work I followed the guides to my device manager where I updated the connected devices drivers and when that didn't work I manually installed the latest USB drivers and android studio(neither helped). I also have on my device PTP file transfer turned on and USB debugging on in developer options. I followed peoples steps for launching unity last and tried changing the USB port I was using to one on the back of the machine. List of things tried: - In project settings under editor I selected any android device - In preferences I have the android JDK, SDK, NDK and everything else in that list checked and installed - On the device I'm trying to project to (samsung tab A) I have PTP file transfer on USB debugging checked location faking on and its update. - I followed a number of guides to installing the latest USB drivers from androids site and android studio - then I tried opening device manager where I updated my devices drivers it now lists the device as "SAMSUNG Android ADB Interface" - and finally I have tried opening unity, opening the unity remote app, and plugging the device in in all the combinations possible. Is there something I need to have in my games code that I don't have? What am I missing here how can I get this issue solved? Thanks for the response in advance!

LayerMask Issue

$
0
0
Hi, In the Unity3DCollege FSM tutorial on Youtube, the following line is used to denote the layer mask: private readonly LayerMask _layerMask = LayerMask.NameToLayer("Walls"); However, this isn't working for me. This is subsequently used in several functions to return a bool, eg: private bool IsForwardBlocked() { Ray ray = new Ray(transform.position, transform.forward); return Physics.SphereCast(ray, 0.5f, _rayDistance, _layerMask); } ...and it constantly returns "False", even when it should return "True". There's nothing wrong with the rest of the code because if I change the layermask line to: int _layerMask = 1 << 8; (as the layer in question is layer 8), everything performs as it should. So - any idea please what the problem is with that initial line? Thanks, A

How to instantiate a prefab declared in one script, from another script

$
0
0
This is script one: - public GameObject chatContent; //this gameobject is referenced in the editor public void Start() { AddMessage("This is ok"); } void OnEnable() { EventSystemManager.StartListening("messageArrived", AddMessage); } public void AddMessage(string message ) { print("One"); GameObject remoteMessage = Instantiate(localMessagePrefab, chatContent.transform) as GameObject; print("Two" ); remoteMessage.transform.GetChild(0).GetComponentInChildren().text = message; print("Three"); DestroyMessage(); } - The method **AddMessage** executed in **Start** method works nice, and also i can execute **AddMessage** several time in the script. The problem is that if i execute this method **AddMessage** from another script it only get up to the **print("One")** in the method but the prefab is never instantiated. I have tried to do it by events and also referencing gameobject from the editor but nothing works. The method is executed but the instatiation fails with no errors. - This is script two with events: private async void onMessageHandler(string e) { serverMessage = JsonUtility.FromJson(e); EventSystemManager.TriggerEvent("messageArrived", serverMessage.normmsg); await miaApi.queueAnim(serverMessage.normmsg); } TIA!

How to stop prefab from resetting its user defined reference variable

$
0
0
I have a monster prefab which has the following movement script attached to it. target is the destination for the monster when I instantiate it. But as soon as I make the object as a prefab by dragging it into the assets,the target variable get reset resulting in the spawned mob just standing still Only number variables stay constant. Are there any workaround to allow the prefab to have a reference of the gameobject?> [SerializeField] GameObject target;>> UnityEngine.AI.NavMeshAgent agent;> // Start is called before the first frame update> void Start()> {> agent = this.GetComponent();> agent.SetDestination(target.transform.position);> }>> // Update is called once per frame> void Update()> {> bool chase = agent.SetDestination(target.transform.position);>> if (chase == true)> {> agent.SetDestination(target.transform.position);> }> }

Trouble connect to service

$
0
0
Hi. Project unity not connect to service. I try create new links but without result, it problem in all projects (olds and new). In game have script connect to my server and it also not work, but game in iphone not have problem with internet. Firewall disabled. Made update then reinstalled, not resolve ![alt text][1] ![alt text][2] [1]: /storage/temp/145075-screen-shot-2019-08-23-at-73642-pm.png [2]: /storage/temp/145076-screen-shot-2019-08-23-at-73736-pm.png

Unity Oculus VR lock rotation of a grabbed object

$
0
0
For an Oculus Quest game i'm working on, I need to be able to grab an object and not rotate it in any way. I should be able to move it in x y and z though. I'm doing this in a climbing game and the object is quite big. My player is locked on (0,0,0) and you climb by grabbing the terrain and moving it, giving the illusion that you are climbing ---------- I am using Unity's Oculus integration asset and I have the OVR Grabbable script on the object I want to be able to grab. ---------- I've tried using a rigidbody and locking the rotation like that, but that doesn't work. Once I grab it, I can still rotate the object. ---------- I've also tried adding a bit of code in the script, which would reset the objects rotation in the fixed update, but that caused my game to freak out big time, so that's not a good idea either. ---------- I am not using VRTK, because that does not work with the type of climbing I'm trying to achieve. ---------- Do you have any ideas on how to lock this objects rotation while it's being grabbed? Please send them my way.

The type or namespace name `IPostprocessBuildWithReport' could not be found though I'm using it.

$
0
0
Hello, Please help me I really want to get it done. Basically, I want to copy files from the "Assets/Files" folder to the "*_Data/Resources" folder when build finishes. I get these errors for whatever reason... ![alt text][1] I'm using everything needed for that. My code: using System.Collections; using System.Collections.Generic; using System; using System.IO; using UnityEngine; using UnityEditor; using UnityEditor.Build; using UnityEditor.Build.Reporting; public class PostBuild : IPostprocessBuildWithReport { private List files = new List(); public int callbackOrder { get { return 0; } } public void OnPostprocessBuild(BuildReport report) { files.Add("/file1.ico"); files.Add("/file2.xml"); files.Add("/file3.xml"); files.Add("/file4.xml"); for (int i = 0; i < files.Count; i++) { File.Copy(Application.dataPath + "/Files" + i, Application.persistentDataPath + "/Resources" + i); } Debug.Log("PostBuild.OnPostprocessBuild for target: " + report.summary.platform + " at path " + report.summary.outputPath); } } Can someone explain to me what I'm doing wrong and how to fix it? [1]: /storage/temp/145077-screenshot-3.png

Unity 2019.2 can't locate ndk or use ndk

$
0
0
I have been trying to get this fixed but nothing helped. i tried linking a new direcotory. already annoying that it searches for itself and it doesn't open finder so i can put mine in. both the one with unity hub installed and the one i linked don't get recognised. after that i downloaded the newest r19 NDK and put it in the NDK folder of the editor and placed the preinstalled away. but yet again nothing. ![alt text][1] ![alt text][2] ![alt text][3] how can i fix this? it only happened after going from 2018.3 to 2019.2 . i didn't update for a long time. i still have version 2018.3 located on my internal drive. and the 2019.2 is on my external drive. if that is info that helps. it's annoying cause i can't do anything right now. [1]: https://i.imgur.com/IUT9OSk.png [2]: https://i.imgur.com/vssCMsN.png [3]: https://i.imgur.com/ITby7Ie.png

Sending data from Android to mysql database.

$
0
0
Hi everyone! I'm currently working on a new project. I followed this tutorial to set up a database. https://www.youtube.com/watch?v=SKbY-0zt2VE I have everything working on my computer and I can save usernames & passwords at the database without problems but whenever I build and run the program, and test it on Android, It won't work and it returns unknown error. I'm wondering what I should do next to access the database(send data to database such as username & password) from any android device. I used Mamp to set the database up. Does anyone have any experience? Thanks in advance!

Orange textures on Older Machines?

$
0
0
I'm trying to track down this bug for older Intel Integrated Graphics machines. On my newer Windows 10 machine the game runs fine, but on older machines I get Orange areas and other texture errors: ![Error version][1] And here is the correct Version: ![Correct Version][2] Things this is not: Z - Fighting (As multiple shaders are affected), An old graphics driver (as we updated to the current drivers from intel) **What could make textures appear Orange on some systems but not all systems?** Affected machines all have intel integrated graphics cards but are windows 7, windows 8,1, 32 bit and 64 bit. (Please don't reply that we should stop supporting older machines, that is not helpful.) [1]: https://forum.unity.com/attachments/image_2019_07_07t00_48_01_475z-png.447353/ [2]: https://forum.unity.com/attachments/screenshot-2019-07-08-16-56-30-png.447356/

Build data path and projects data path on postprocess build.

$
0
0
How do I distinguish the project's data path and the build data path on postprocess build? I want to copy files from project's assets' folder ("Assets/Files") to build data's folder ("*_Data/ Resources"). How do I do it? When I just do this: File.Copy(Application.dataPath + "/Files" + file, Application.persistentDataPath + "/Resources/"); Unity thinks I want to copy files from ("Assets/Files") to ("Assets/Resources") but I want to copy the files to built application's data folder. How to do it?

Rebinding input at runtime using the new input system

$
0
0
So recently i have been looking for a way to make an options menu for rebinding keys during the game, and from what i understood after my research is that unity would not expose the old input system during runtime, and i would have to create a custom input manager as a replacement for the old one, but that seems to be an old solution to create the rebinding menu and customize key bindings at runtime, and surely someone at unity have noticed this issue and thought to implement this as a feature in the new input system, like.. sure someone did, right? so what i am asking is that if is there is a way to customize key bindings during runtime through a menu or somthing like that using the new input system? and if it is possible, HOW???!

How to get pixel coordinates when mouse click on Sprite Renderer

$
0
0
Hi, I have a SpriteRenderer , and Collider2d on that game object. I want to get exact pixel of sprite where mouse click. I tried var pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); then Raycast and textureCoordinate2 to get pixel but not succeeded.

Can't use BuildFile.path.

$
0
0
Why I can't use it? I want to get my built file path. Can someone help me? I'm quite new... I tried this: string pathToExe = BuildFile.path; and It says that BuildFile is a type thus I can't use it... How do I get built executable path?
Viewing all 171066 articles
Browse latest View live


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