_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
0 | How to rotate an object to a specific transform? I am working on a car racing game and there are some times when the car rotates and ends up on its roof. On those situations I want the car to respawn on the same location. What can I do to rotate it so the car ends up on its wheels? |
0 | Unity Editor Adding Object Fields on button click So I am trying to make a button that will spawn an object field and a float field when clicked. Each object field being unique, so I can add gameobjects to it. I can t think of a way to do this. This is purely Editor Scripting. Also, if there is an option to delete a row (the object field and the FloatField) that would be amazing |
0 | How can I change the speed flag for random or not random at run time? This method is being called by Update() private void SpeedUpdater() if (changeSpeedOnce false) foreach (WaypointsFollower follower in waypointsFollowers) if (randomSpeed) follower.speed Random.Range(minRandomSpeed, maxRandomSpeed) else follower.speed speed changeSpeedOnce true I'm using the changeSpeedOnce flag helper to assign the speed to the followers once either random or the constant speed. but then when the game is running changeSpeedOnce is true and if I want to change the randomSpeed flag again I need somehow somewhere to set the changeSpeedOnce to be false again. I don't want to use a button or an input key for that but using the randomSpeed flag. |
0 | Unity Disable push on dynamic Rigidbody2D objects I have a player, and several NPCs. I also have several static colliders in the world (trees, water, fence, etc), I want my NPCs to collide with this, so the Rigidbody2D needs to be dynamic, since kinematic does not collide with static colliders (colliders without a rigidbody). My problem is that since both player and NPC have dynamic rigidbodies, they push each other when they collide. I could disable this by setting the following in the NPC script void OnCollisionEnter2D(Collision2D other) if (other.gameObject.name "Player") isMoving false myRigidBody.isKinematic true However, the NPC still gets pushed a few pixels before it stops, its barely noticable, but it is noticable, and if you keep colliding with the NPC you could move it as far as you wanted (tedious, but possible). I've spent a few hours looking and cannot find a good solution to this. I want my NPC to collide with static colliders, but I don't want them to get pushed by the player. How can I solve this? |
0 | Face Detection in Vuforia Unity Android I am working on face detection in unity.I have tried out a face tracking sample from the below link.It worked fine https github.com marcteys unityFaceTracking The problem is that,when I runned the above project,Am show with a separate camera view window for detection. But when we consider unity android,the tracking should be done through phone camera. Is there any option other than OpenCV. Please help me out |
0 | Why when coloring a Light from green to red it's coloring only part of it in red? I have in the Hierarchy a door with a script attached to it. The script using UnityEngine using System.Collections public class DoorVert MonoBehaviour public float translateValue public float easeTime public OTween.EaseType ease public float waitTime public Light lt public bool doorLocked false private Vector3 StartlocalPos private Vector3 endlocalPos private void Start() StartlocalPos transform.localPosition gameObject.isStatic false if (doorLocked true) for (int i 0 i lt lt.Length i ) lt i .color Color.red public void OpenDoor() if (doorLocked false) OTween.ValueTo(gameObject, ease, 0.0f, translateValue, easeTime, 0.0f, "StartOpen", "UpdateOpenDoor", "EndOpen") GetComponent lt AudioSource gt ().Play() private void UpdateOpenDoor(float f) if (doorLocked false) Vector3 pos transform.TransformDirection(new Vector3(0, 1, 0)) transform.localPosition StartlocalPos pos f private void UpdateCloseDoor(float f) if (doorLocked false) Vector3 pos transform.TransformDirection(new Vector3(0, f, 0)) transform.localPosition endlocalPos pos private void EndOpen() if (doorLocked false) endlocalPos transform.localPosition StartCoroutine(WaitToClose()) private IEnumerator WaitToClose() yield return new WaitForSeconds(waitTime) OTween.ValueTo( gameObject,ease,0.0f,translateValue,easeTime,0.0f,"StartClose","UpdateCloseDoor","EndClose") GetComponent lt AudioSource gt ().Play() I added the doorLocked bool variable. And i want that when it's true and the door is on locked state to change the color of the two Point light 1 from green to red. In the Start i did if (doorLocked true) for (int i 0 i lt lt.Length i ) lt i .color Color.red When i'm running the game and doorLocked is false this is how it looks like Both lights are green and i selected one of the Point light 1 and you can see in the inspector the Color is green Now this is a screenshot when the game is running and when lockedDoor is true. Now it should be red but it's only red around the Point light 1 the color seems to be still green Now i saw that in the Hierarchy one object above Point light 1 is called Light Small 02 it's a child also of Light Small 02 I marked it here with a black circle. And i think that i need also to change this Light Small 02 color from green to red. Not sure since i can't find any green color with it in the inspector but when i disable the Light Small 02 the green color is gone. Anyway the main goal is to change the color of the two lights according to the door state doorLocked true false This is a screenshot of Light Small 02 inspector showing the mesh renderer part |
0 | Tetris block kinematic rigidbodies pass through one another with Transform.Translate I am trying to build a Tetris 3D game in Unity but I am stuck at getting the different blocks to interact (to detect each other, to sit one on top of the other rather than going through each other). I have set the ground with a box collider and the spwaned blocks come in with rigidbodies and trigger colliders. This works for them to nicely settle on the ground but when I try to sit a block on top of another block they both have kinematic rigidbodies and the collision detection doesn't work and they end up overlapping. The problem is if I remove the rigidbody of the already settled block then it will go through the ground. Any idea how to get 2 spawned objects to detect each other? using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UIElements public class moveBlock MonoBehaviour public static float speed 2 public GameObject blocks public static List lt GameObject gt blocksSpawned new List lt GameObject gt () public static List lt Rigidbody gt blocksRBSpawned new List lt Rigidbody gt () public static bool triggerPlatform true Rigidbody rb void Update() Vector3 input new Vector3(Input.GetAxisRaw( quot Horizontal quot ), 0, Input.GetAxisRaw( quot Vertical quot )) Vector3 direction input.normalized Vector3 velocity direction speed Vector3 moveAmount velocity Time.deltaTime if (triggerPlatform) blocksSpawned.Add((GameObject)Instantiate(blocks Random.Range(0, 7) , new Vector3(0, 6, 0), Quaternion.Euler(Vector3.right))) rb blocksSpawned blocksSpawned.Count 1 .GetComponent lt Rigidbody gt () blocksRBSpawned.Add(rb) triggerPlatform false if (!triggerPlatform) Destroy(blocksRBSpawned blocksRBSpawned.Count 1 ) if (blocksSpawned blocksSpawned.Count 1 ! null) blocksSpawned blocksSpawned.Count 1 .transform.Translate(Vector3.down Time.deltaTime speed, Space.World) blocksSpawned blocksSpawned.Count 1 .transform.Translate(moveAmount) using System.Collections using System.Collections.Generic using UnityEngine public class trigger MonoBehaviour private void OnTriggerEnter(Collider other) moveBlock.triggerPlatform true |
0 | Photon2 billboards take a long time to face the camera I'm using PUN2 and trying to use nametag billboards for my players, but they are not facing forward correctly and I have to wait more than 20 seconds to make the name tag of player return to facing forward. here's my code for my BillBoard Script public class BillBoard MonoBehaviour protected Transform ThisCameraPlayerBillBoard private void Start() ThisCameraPlayerBillBoard GameSetup.GS.ThisCameraToBillBoard.GetComponent lt Camera gt ().transform private void FixedUpdate() transform.LookAt(transform.position ThisCameraPlayerBillBoard .rotation Vector3.forward, ThisCameraPlayerBillBoard .rotation Vector3.up) |
0 | Moving directional light cause huge fps drop why? I've implemented a simple script to simulate Sun Rotation (day night cycle). In my "Update" i Rotate main Directional Light (the sun). What i've noticed is that my FPS dropped from 60 to 20 25 fps. I can understand why recalculate all light each frame can be (euphemism) cpu consuming. So i switched approach using an InvokeRepeating with a repeating time of 0.25f seconds (4 "movement" per second). Also with this approach my frame rate drop from 60 to 50 (unacceptable). So my question is is there a way to move rotate a light (simulating a day night cycle for instance) without meet a so big fps dropping but mantaining realism ? Thanks |
0 | missing editor version 5.5.1f1 on this machine. Select another version from the list unity missing editor version 5.5.1f1 on this machine. Select another version from the list unity am new to unity please help someone thanks |
0 | How do I get my mouse based input system to work on Android? I am developing the ball breaker game in unity and right now my game work with mouse click button. but i want my game work in android. so what changes i want to do in this code? So when i set the arrow and its jump ball and hit the brick. Here is the code with image BallController.cs using System.Collections using System.Collections.Generic using UnityEngine public class BallController MonoBehaviour public enum ballState aim, fire, wait, endShot public ballState currentBallState public Rigidbody2D ball private Vector2 mouseStartPosition private Vector2 mouseEndPosition private float ballVelocityX private float ballVelocityY public float constantSpeed public GameObject arrow Use this for initialization void Start () currentBallState ballState.aim Update is called once per frame void Update () switch (currentBallState) case ballState.aim if (Input.GetMouseButtonDown (0)) MouseClicked () if (Input.GetMouseButton (0)) MouseDragged () if (Input.GetMouseButtonUp (0)) ReleaseMouse () break case ballState.fire break case ballState.wait break case ballState.endShot break default break public void MouseClicked() mouseStartPosition Camera.main.ScreenToWorldPoint(Input.mousePosition) Debug.Log (mouseStartPosition) didClick true public void MouseDragged() didDrag true Move the Arrow arrow.SetActive(true) Vector2 tempMousePosition Camera.main.ScreenToWorldPoint(Input.mousePosition) float diffX mouseStartPosition.x tempMousePosition.x float diffY mouseStartPosition.y tempMousePosition.y if (diffY lt 0) diffY .01f float theta Mathf.Rad2Deg Mathf.Atan (diffX diffY) arrow.transform.rotation Quaternion.Euler (0f, 0f, theta) public void ReleaseMouse() arrow.SetActive (false) mouseEndPosition Camera.main.ScreenToWorldPoint(Input.mousePosition) ballVelocityX (mouseStartPosition.x mouseEndPosition.x) ballVelocityY (mouseStartPosition.y mouseEndPosition.y) Vector2 tempVelocity new Vector2 (ballVelocityX, ballVelocityY).normalized ball.velocity constantSpeed tempVelocity if (ball.velocity Vector2.zero) return currentBallState ballState.fire |
0 | Is there performance difference between OnCollisionEnter and OnTriggerEnter? Is there performance difference between OnCollisionEnter and OnTriggerEnter? I have around 12 objects all calling OnCollisionEnter when in fact OnTriggerEnter could work as well. So I wonder if the are is any difference PERFORMANCE WISE between the two |
0 | Problem finding correct value for Yaw I use an Arduino and a 9dof sensor ( gyroscope, accelerometer and magnetometer ) and i'm trying to use the pitch, roll and yaw that the sensor gives me to rotate an object in unity. I managed to correctly compute pitch and roll ( the z and x axis in unity ) from the accelerometer but it seems that I can't get the Yaw right. By that I mean that when I rotate my sensor pitch or roll it rotates my Yaw too in a weird way. Code in the arduino to get the heading void getHeading(void) heading 180 atan2(Mxyz 0 ,Mxyz 1 ) PI if(heading lt 0) heading 360 void getTiltHeading(void) float pitch asin( Axyz 0 ) float roll asin(Axyz 1 cos(pitch)) float pitch atan( Axyz 0 sqrt( Axyz 1 Axyz 1 Axyz 2 Axyz 2 ) ) float roll atan( Axyz 1 sqrt(Axyz 0 Axyz 0 Axyz 2 Axyz 2 )) float xh Mxyz 0 cos(pitch) Mxyz 2 sin(pitch) float yh Mxyz 0 sin(roll) sin(pitch) Mxyz 1 cos(roll) Mxyz 2 sin(roll) cos(pitch) float zh Mxyz 0 cos(roll) sin(pitch) Mxyz 1 sin(roll) Mxyz 2 cos(roll) cos(pitch) tiltheading 180 atan2(yh, xh) PI if(yh lt 0) tiltheading 360 Pitch and roll float Pitch (float)(180 Math.PI Math.Atan( m ResultX Math.Sqrt( m ResultY m ResultY m ResultZ m ResultZ ) ) ) float Roll (float)(180 Math.PI Math.Atan(m ResultY Math.Sqrt(m ResultX m ResultX m ResultZ m ResultZ))) float Yaw (float)(m TiltHeadingResult) Don't hesitate to ask for details. |
0 | Unity3d wheelcollider falling through terrain I have created simple project with 3D car and terrain. I have added 4 Wheel Colliders on model wheels. But when I run project wheels falling through terrain. Before run After run I am sure that at start wheel colliders above the terrain and not intersect it. Configuration is In what problem is? I have tried a lot of different things but I can't find a solution. |
0 | Architecture of "doodle jump" type gameplay infinite looping background I am planning make a doodle jump type game, character jumping on platforms. A scrolling or doodle jump like background which ll appear to move when character moves upward and appear moving (just like in doodle jump) so, my thoughts are for this kind of background is to take a large image i.e of 2048x2048, make 2 planes, set this texture to them, when first image ends other ll move its position on top of first, when second ends first ll move on top of second and so on. Other approch could be a "Instantiate" and "Destroy" of small images having textures on them according to jumping character position ( which i doubt ll b expensive ) They are my thoughts, I want to go for best approach and would like to listen the best one. Is there any more appropriae way to achieve moveable background, I ll appreciate your suggestions. Thanks. |
0 | In Unity, what does the camera script's "Behaviour missing" error mean? I started in Unity few days ago and made a cube with a tank control style. Now I'd like to create controls similar to 3D fighting games (Gunz, Blade Symphony, ) Control body direction with the mouse and walk with WASD. However, the Camera is giving me a error called "Behaviour missing" each time I try, with all the cameras scripts I saw. I think that is a error with tagging the character movement in the camera, but I don't know how to do that. What might be the problem? |
0 | How to make a procedural tilemap island with more than one tile in unity? I have been working on a simple survival game. I made the character and some basic elements (I'm new to the field though). But what I could figure out how to make is the world generation. I just wanted to make a program that generates an island procedurally. I tried Perlin Noise before, but it wasn't that efficient. The results were too random. In the past few days, I found a unity package that generates tilemap islands, and I really liked the results, but I didn't know how to make more tiles than just grass. The problem is that I don't know how can I make a script like this because I am still new to unity. That's why I tried asking for some help. I just want something that looks like this I would really appreciate any help! |
0 | C store functions with parameters in a List I want to store functions with parameters in a List, so that I can call them at a later stage. Let's say (this is rough code) void Func1(int index) Debug.Log("Func1" index) void Func2(int index) Debug.Log("Func2" index) . . . void Store(Func1(1)) list.Add(Func1(1)) void Replay(int position) list position () this calls the function with the parameter |
0 | How to store and organize my data in a JRPG style game? I am trying to make a JRPG style game using Unity. See this image below to get a sense of the "feel" of the type of game I am making http www.juicygamereviews.com uploads 3 0 5 0 30501048 9185639 orig.jpg Currently I'm struggling to find a good way to organize the data in my game. Referring to the image above, see how each party member has stats, as shown in the UI? I'm sure the monster also has the same kinds of stats, just hidden away. Hence, I want to make a struct called Stats, that both PartyMembers and Monsters contain a reference to. To summarize what I'm saying so far Right now I'm pretty sure I want two classes one called PartyMember and one called Monster, both of them deriving from a common class I'll call it TurnTaker that takes turns during battle. In the TurnTaker class I want a reference to a struct called Stats, which contains HP, MP, Attack, Defense, etc. The problem is, for player data I want the Stat class to be Serializable because I want to save player progress in a binary format, yet for Monsters I wish to make the Stat class inherit from Scriptable Object (SO) for easy development and editing. Is it possible to make Stats both serializable and derive from SO in Unity? (Note a struct cannot derive from SO only a class can. Should I change my stats from a struct to a class? Seems a bit of a waste, just for the inheritance functionality.) Further, I'm thinking party members have data specific to themselves (equipment, total EXP, character class, etc), as do monsters(drop items, movement type, etc.) Should I make these two "things," I'll call them PartyMemberSpecificData and MonsterSpecificData separate classes altogether separate interfaces that attach themselves to PartyMember, Monster, or Stat classes that derive from Stats (I think I want PartyMember to contain a reference to PartyMemberSpecificData and Monster to contain a reference to MonsterSpecificData.) Any help appreciated! |
0 | Is it possible in Unity to Flip a 2D Sprite Without Flipping the Object it is Assigned to? I 'built' (followed a tutorial) on a collision detection system, and when I flip the object to go left and right the collision messes up. So I have three options find a way to modify the collision detection, have sprites for all animations for left and right or to flip the sprite but no the object. if anyone has used RaycastHit2D, and has figured out a way to do it correctly, that would also be great. |
0 | When creating a game, what are some architectural desgin concepts I can use to be able to port my game from single to multiplayer? I am a software developer but, I mostly develop games in Unity. I have experience creating single player games as well as multiplayer games. I am at a crossroads where I am in the middle of development of a proof of concept or small demo and all of a sudden I am asked to turn it into a multiplayer game without prior knowledge of this I turn around and say it would add 50 to development time because I basically have to start over from scratch because I didn't necessarily take into account that later down the road they might want to change the experience from single to multiplayer. So with all of that out of the way, are there any different methodologies out there that would make it easier on the developer to port a game from single player to multiplayer? I have thought of a possible way of doing this by just setting the game up as single player, however, making my functions where they are easily able to wrap them using Commands and RPCs. But I find this may or may not help me and is only dependent on what the requirements are. My biggest time killer when it comes to porting these PoC's is typically the UI. Most of the time my requirements are so that the UI will be the same shared UI for all clients and having to update it for each action performed on it and dealing with handling ClientAuthority. (Any tips for dealing with this would be greatly appreciated too) Think of this as something like, making something with Legos in multiplayer and having shared instructions based on the step the user is on. Summary What are different ways that I can design a small demo concept where I can easily port it to multiplayer later on, or make my game where it is "multiplayer friendly" ? Or should I try to stay away from this type of thinking altogether and just develop a single player aspect and just develop a multiplayer aspect, arguments for and against this concept are sought after. |
0 | Mirror problems after building game in unity Hi I am facing a weird problem in unity when I build a particular scene. Here is the screenshot of how the mirror looks when I play the game from inside the unity editor And here is how it looks once I build this scene and then play it The quality settings at Edit Project Settings Quality are these And the player settings at File Build Settings Player Settings are these So how do I fix this? What do I need to change or is there any other entity? |
0 | Can I output a text file on build with build details in it? We have an issue with organizing our builds. They get copied around and moved so much that it's hard to keep track of what is the newest. I would like to output a simple text file to the build root (same level as exe) that contains info like the build date and time, platform, etc. Is this possible from within Unity? Right now we have no automated build process (CI CD). edit I found onPreprocessBuild() but unfortunately one of our main projects still uses Unity 5.3.6f1, so this will not work. Is there an alternative? |
0 | Hardcode per instance properties into the shader in unity I am using one of the packages from the asset store and using its Polyline feature for wire rendering. There are thousands of wires and its taking much fps Batch counts. The reason of the lack of support for static batching. Now there is a workaround suggested by the author of the package. if you don't use polylines for anything other than that, and all your shaders use the same properties, you could hardcode all per instance properties into the shader Due to a lack of shader knowledge(I am developing the knowledge currently and it will take time) I am unable to hard code the above properties I tried and here is the current scenario define int ScaleMode 1 define half4 Color (0,0,0,0) define float4 PointStart (0,0,0,0) define float4 PointEnd (0,0,0,0) define half Thickness 0.5 define int ThicknessSpace 1 define half DashSize 1 define half DashOffset 1 define int Alignment 1 HOw do i correctly hard code above values? |
0 | Why I can't do a build for Linux? I'm using Unity 5.3.x (free version) on a Windows machine. I would like to build my simple desktop game either for Windows and Linux, but Linux (and Mac) build is disabled. Am i missing something ? Thanks |
0 | Why isn't my rotation smooth? I'm currently working on a twin stick shooter but I encountered a problem when I rotate my player. The rotation snaps to right angles. I'm guessing it's a problem, due to the value that the joystick gives me back. Here is a screen recording, via Giphy. How do I go about fixing this problem? This is my code void FixedUpdate() float hR gamepad.GetStick R().X float vR gamepad.GetStick R().Y float lastHR hR float lastVR vR This part was added recently in the hope of smoothing the rotation float lerpHr Mathf.Lerp(lastHR, hR, Time.deltaTime speedRotation) float lerpVr Mathf.Lerp(lastVR, vR, Time.deltaTime speedRotation) PlayerRotation(lerpHr, lerpVr) void PlayerRotation(float h, float v) rotation.Set(h, 0f, v) if (rotation ! Vector3.zero) currentRotation Quaternion.LookRotation(rotation) playerRigidbody.MoveRotation(currentRotation) lastRotation currentRotation else playerRigidbody.MoveRotation(lastRotation) I also tried two other ways, but each time, I got the same results. I tried every way I could think of, with these lines of code. I don't know where else to look. Attempt Two playerRigidbody.transform.rotation Quaternion.Slerp(p layerRigidbody.transform.rotation, currentRotation, Time.time speedRotation) Attempt Three transform.eulerAngles new Vector3(0, Mathf.Atan2(v, h) 180 Mathf.PI, 0) |
0 | How to change the pivot in Unity? I have a cube created in Unity scaled 5 times. The pivot of the cube is by default in center. I would like to change the pivot to the one of the vertices. How to do that ? |
0 | Rotation of sprite is not smooth I am making a speed meter of car. Its pretty simple when ever speed increases or decreases the meter pin moves accordingly. I have done the movement part of pin but I am unable to get a smooth movement. public Image meterPin const float maxPinAngle 116f const float minPinAngle 16f float meterMinSpeed 10f float meterMaxSpeed 210f void Update() changeMeterSpeed() void changeMeterSpeed() meterMinSpeed userSpeed meterMinSpeed Mathf.Clamp(meterMinSpeed, 0f, meterMaxSpeed) meterPin.transform.eulerAngles new Vector3(0, 0, getTransformRotation()) float getTransformRotation() float totalAngle minPinAngle maxPinAngle float speedNormalized meterMinSpeed meterMaxSpeed return minPinAngle speedNormalized totalAngle The userSpeed value is calculated in another function in this script. The only issue is that the movement is not smooth. Any ideas if I can fix the smoothness issue in this script. EDIT Here is a gif to explain whats happening. Thanks |
0 | can someone help me with this code for my platformer. ive been working on the script for an eternity but unity keeps saying there is an error using UnityEngine using System.Collections public class player controler MonoBehaviour public float moveSpeed public float jumpHeight Use this for initialization void Start () Update is called once per frame void Update () if(Input.GetKeyDown) (KeyCode.Space)) rigidbody2d.velocity new vector2(0,jumpHeight ) This is what shows up Assets scripts player controler.cs(16,53) error CS0201 Only assignment, call, increment, decrement, and new object expressions can be used as a statement |
0 | Is Unity NGUI still that usable after Unity has add support for 2D? I am tempted to refactor out the existing component which uses NGUI ("Next Gen UI kit") given that what I needed is only the sprite and texture atlas. Since in the newer versions of Unity those parts are natively supported, is there any reason I should still keep NGUI? |
0 | Resolve Unity error about "Constructors and field initializers" on the loading thread The code below is producing an error message I don't understand Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function I don't know where the problem is in my code or what I need to change can someone please explain? var XPos float transform.position.x var YPos float transform.position.y var ZPos float transform.position.z var Waiting float 0.02 function OnTriggerEnter (col Collider) if (col.gameObject.tag "Player") this.transform.position Vector3(XPos, YPos 0.1, ZPos) yield WaitForSeconds(Waiting) ...similar code omitted transform.GetComponent. lt Collider gt ().isTrigger true Destroy(gameObject) |
0 | .png file to Sprite(2D and UI) still not visible under source image I am trying to use an image as a UI Image but even after changing its texture type to Sprite(2D and UI), it isn't visible in the source image menu. The file was created in MS Paint and I'm accessing the source image menu via the "circle selector" next to Source Image in the Inspector. I'm pretty sure I've never had this issue before. I wish I could share more details but there's nothing much to say. What could be causing this issue? |
0 | Vuforia is not rendering real world Camera not rendering real world I follow this guide (How to build an ar android app with vuforia and unity) but added my own mobile picture in database (as a marker) so that I could see animated object on my mobile and i am able to run my app but camera is not rendering the real world object in scene. instead animated object showing only. what i am doing wrong? Remember vuforia doesn't recognize my web cam profile and apply default profile on it.(Is this a problem ) |
0 | Is a 3D renderer with 1000 FPS possible? Okay, for my phD Thesis, I need to make a simple 3D game, like towers of hanoi or whatever but there is a condition I need it to have high FPS, as in, the highest FPS achievable, atleast a 1000FPS. I need to have a high FPS to measure reaction times. We achieve this with 1ms monitors BUT on the programming front, here is the problem, I'm confused if I should code an entire specially made engine with only the features I need (using Vulkan), and if I did would it be faster than already available engines like Unity or Unreal? Would it be worth the time and effort or can these engines be customised themselves and is that easier than doing it from scratch? Or is it only achievable with specialized hardware? So I'd be better of using an available engine and going hard on the hardware? |
0 | How do I find all game objects with particular name? I'm trying to mimic FindGameObjectsWithTag with FindGameObjectsWithName. I know using tags is faster, but I'm trying create a way to search for objects I spawn with a child object I name on instantiation through the inspector. My goal is create multiple enemy spawners. My current spawner has a drag and drop variable for enemy prefabs. It looks for enemies tagged "ReSpawn", then checks if that length is below a value, to start spawning more. I would like to upgrade my current single spawner to still check for enemies named "ReSpawn", but then check if those respawns have a child object a name specified in the editor. This way, I can set the enemy spawners anywhere (e.g. near water, tall grass, forests, etc), and when I defeat one, the specific spawner will instantiate one of its opponents for that area. Here is my code, so far var ThisSpot String var Oppos GameObject var OppoCount GameObject var HowMany 3 var spawnSizeArea 25 function Start() StartCoroutine ("Spawn") function Update () OppoCount GameObject.FindGameObjectsWithTag("Respawn") OppoCount GameObject.FindWithName(ThisSpot) This is what I am trying to achieve if(OppoCount.length lt HowMany) StartCoroutine ("Spawn") function Spawn() var length Oppos.length 1 var index Mathf.Round(length UnityEngine.Random.value) curSpawn Oppos index var xz Random.insideUnitCircle spawnSizeArea var newPosition Vector3(xz.x,0,xz.x) transform.position yield WaitForSeconds(Random.Range(70,120)) Instantiate(curSpawn, newPosition, transform.rotation) Then I could use these 2 lines of code below to use multiple spawners var newOp GameObject Instantiate(curSpawn, newPosition, transform.rotation) newOp.transform.Find("fighter").gameObject.name ThisSpot StopCoroutine("Spawn") |
0 | submeshes and dynamic batching doesnt work as expected I'm duplicating one object with submeshes frequently, and assigning a random material from five materials to each submesh. There is batching happening, but it's not quite as efficient as I would have expected (details here). Note objects are all less 900 vertices no light maps and ... All are dynamic batching ready So if dynamic batching works there must be only 5 draw calls right but there isn't there is really much more than 5 |
0 | How do I programmatically change the areaSize variable of an Area Light object in Unity? I'm trying to change the areaSize property of an Area Light object, but it looks like it isn't exposed in the class, itself. this.light.areaSize new Vector2(this.areaLightWidthSlider.Value, this.areaLightHeightSlider.Value) This code results in the error error CS1061 'UnityEngine.Light' does not contain a definition for 'areaSize' and no extension method 'areaSize' accepting a first argument of type 'UnityEngine.Light' could be found (are you missing a using directive or an assembly reference?) The documentation says it exists, as an "editor only" property. Is there any way to programmatically access and change this property, possibly using reflection or serialized properties? I am using Unity 4.6, if at all relevant. |
0 | Unity virtual joystick jarring movement I'm creating an infinite flyer game in which you control the plane using a mobile joystick. There are two controls one to rotate the plane and the other to move the plane. While rotating the plane there is a lot of jarring if I use Time.deltatime. There is no jarring when I don't use Time.deltatime. This is the line of code that use Time.deltatime transform.rotation initialRotation Quaternion.Euler( pitchTime.deltaTime, yawTime.deltaTime, 0). Here is the code in the Move script public class Move MonoBehaviour public Joystick joystick public Joystick joystick1 float rotateVertical float rotateHorizontal public float sensitivity Quaternion initialRotation float pitch, yaw float moveHorizontal float moveVertical void Start() initialRotation transform.rotation void Update() pitch pitch joystick.Vertical sensitivity yaw yaw joystick.Horizontal sensitivity transform.rotation initialRotation Quaternion.Euler( pitch Time.deltaTime, yaw Time.deltaTime, 0) transform.Translate(moveHorizontal Time.deltaTime, moveVertical Time.deltaTime, 0) There is also a camerafollow script attached. SerializeField Transform target public Vector3 defaultDist new Vector3(0f, 0, 7.5f) SerializeField float distDamp .1f public Vector3 velocity Vector3.one Transform myT void Awake() myT transform void LateUpdate() SmoothFollow() void SmoothFollow() Vector3 toPos target.position (target.rotation defaultDist) Vector3 curPos Vector3.SmoothDamp(myT.position, toPos,ref velocity ,distDamp) myT.position curPos myT.LookAt(target, target.up) |
0 | Closest node in A pathfinding For my 2D Unity game, I've implemented A pathfinding based on waypoints. System already handles building graph from waypoints on scene (which are manually placed objects), as well as finding and caching closest routes. So, general idea is to select closest waypoint to character, closest waypoint to target position, and use pathfinding algorithm to find closest route (which is pre cached already). Yet, I've stumbled into issue I don't know how to actually get closest waypoint. Well, there are several ways I think of, in the worst case I can just brute force closest non blocked waypoint from the collection, but that would be bad performance wise. So, are there any proper ways to get start or end points? |
0 | Unity Trail Renderer artifacts flickering disappearing I have a projectile prefab that have 2 trail renderers attached to it. Whenever I instantiate another projectile, every trail renderer seems to flicker. This is similar to the question Changes to one Unity trail renderer causes all of them to flicker In addition to that, I have other rendering artifacts as well. Having too many trail renderers seems to cause some of them to not draw. Also, sometimes, they just seem to randomly choose not to draw. As you can see, the left most projectile doesnt want to draw its trail. Similarly, adding more projectiles, the front projectiles seems to lose all of its trails. So thus, the 2 issues I am having is Flicking trail renderers when another is instantiated. Trails not rendering randomly. Unity Version 5.3.2f1 |
0 | What is the best way to increase slowly object movement speed and slow down the object near the end? There a Lerp but also SmoothDamp. In this script I'm using SmoothDamp but why not using Lerp ? And how should I use this script with the SmoothDamp tp make slowly increasing speed at the start ? Now it's only slow down at the end but I want it also to increase slowly at the start and then slowly down near the end. using System.Collections using System.Collections.Generic using UnityEngine public class MovementSpeedController MonoBehaviour public Transform target private Vector3 velocity Vector3.zero public float smoothTime 0.3F void Update() transform.position Vector3.SmoothDamp(transform.position, target.position, ref velocity, smoothTime) |
0 | Screen Capture rendered on a RenderTexture in Unity I have a pretty wild idea for a unity application that would work on a multi display setup. The app would be running in full screen mode on one of my displays, and the contents of the remaining two displays should be rendered in game on a texture. I've seen RTMP clients for unity and I've tried streaming my desktop with OBS to a local RTMP server but the delay was too big (more than 5 seconds). I would prefer an instant (or very low delay) solution for mirroring my displays on textures in Unity. If anyone can help me solve this, i would appreciate it! |
0 | Unity protect MonoBehaviour derived classes from instantiating via new in C When the class hierarchy grows and you deal with a lot of custom types in your project, it sometimes becomes hard to remember which types are allowed to be created via new and which types are derived from MonoBehaviour and therefore can't be created via new but must instead be attached to the GameObject as a Component. Is it possible to have some safety mechanism for this? The goal would be to have two base classes to control the ability to use new on a certain type. Ideally resulting in a compile time error instead of an easy to miss warning in the console ("You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. Blah blah."). My attempt to make the constructor protected, like this public class UnCreatableBase MonoBehaviour protected UnCreatableBase() using new should be not allowed public static T Create lt T gt () instead this method allows object creation return GameObject.Instantiate (Resources.Load ("Prefabs " typeof(T).Name) as GameObject).GetComponent lt T gt () public class CreatableBase public CreatableBase() new is ok here still allows me to write var whyDoesThisWork new UnCreatableBase() I can access the protected constructor even from an outside scope. Now, the obvious solution would be to make constructors of MonoBehaviour derived classes private. Manually. All of them. Manually. I was wondering if there's a way of achieving the same in a more generic way. |
0 | Get all the gameobjects for a SceneManager scene in Unity I'm using the new SceneManager to load multiple scenes in the same structure adopting the Additive method. I find it extremely useful but I wonder if there is a way to get all the GameObjects for a specific scene. When multiple scenes are loaded I see the GameObjects clearly separated by scene in the hierarchy but I cannot find a way to access the specific hierarchy of a single scene via script. Is that possible? The findGameObject method I think returns the GameObjects for all the scenes.. |
0 | Unity mouse input not working in webplayer build I have a button script with the following code void OnMouseDown() animation.Play("button squish") enlarged true audio.PlayOneShot(buttonSound) void OnMouseUpAsButton() if (enlarged) SelectThisButton() enlarged false animation.Play("button return") void OnMouseExit() if (enlarged) enlarged false animation.Play("button return") It works great in the editor, but when I made a build and tested it in Chrome none of the buttons had any response. Further testing revealed that it did work in Firefox. Rather than telling people to change their browser if they want to play, I want to make the button code work. How else can I get the buttons to know when they're being pressed if the built in stuff isn't working? |
0 | How can I make a character crouch? I tried to make a crouch system. In my script I changed .height and .center properties of collider in CharacterController component. But there are some problems. First, once I press "crouch button" collider is changing its height and center position but when I release the key the collider isn't returning to its previous state. Secondly, if I change its height and position by hand when collider is under a block, it's just stuck. How can I fix this problem? Here's my script using System.Collections using System.Collections.Generic using UnityEngine RequireComponent(typeof(CharacterController)) public class PlayerController MonoBehaviour public float moveSpeed public float jumpForce public CharacterController controller public GameObject myCamera private Vector3 moveDirection Vector3.zero public float gravityScale public Animator anim Use this for initialization void Start () transform.tag "Player" controller GetComponent lt CharacterController gt () Update is called once per frame void Update () Vector3 forwardDirection new Vector3 (myCamera.transform.forward.x, 0, myCamera.transform.forward.z) Vector3 sideDirection new Vector3(myCamera.transform.right.x, 0, myCamera.transform.right.z) forwardDirection.Normalize () sideDirection.Normalize () forwardDirection forwardDirection Input.GetAxis("Vertical") sideDirection sideDirection Input.GetAxis("Horizontal") Vector3 directFinal forwardDirection sideDirection if (directFinal.sqrMagnitude gt 1) directFinal.Normalize () if (controller.isGrounded) moveDirection new Vector3(directFinal.x, 0, directFinal.z) moveDirection moveSpeed if (Input.GetButtonDown("Jump")) moveDirection.y jumpForce if(Input.GetButtonDown("Crouch")) controller.height 1f controller.center new Vector3(0f, 0.5f, 0f) moveSpeed 3f moveDirection.y moveDirection.y (Physics.gravity.y gravityScale Time.deltaTime) controller.Move(moveDirection Time.deltaTime) anim.SetBool("isGrounded", controller.isGrounded) anim.SetFloat("Speed", (Mathf.Abs(Input.GetAxis("Vertical")) Mathf.Abs(Input.GetAxis("Horizontal")))) Thanks for any help! |
0 | Why am I getting errors like these when trying to build my app I am currently trying to build and publish my app to the universal windows platform halfway through the process of doing so, during the validation process I got stopped with these errors. The 1st one I am clueless to what I can even do and the second one I don't know why is happening. Please help. First error Supported API test FAILED Supported APIs Error Found The supported APIs test detected the following errors API D3D12GetDebugInterface in d3d12.dll is not supported for this application type. UnityPlayer.dll calls this API. Impact if not fixed Using an API that is not part of the Windows SDK for Windows Store apps violates the Windows Store certification requirements. How to fix Review the error messages to identify the API that is not part of the Windows SDK for Windows Store apps. Please note, apps that are built in a debug configuration or without .NET Native enabled (where applicable) can fail this test as these environments may pull in unsupported APIs. Retest your app in a release configuration, and with .NET Native enabled if applicable. See the link below for more information Alternatives to Windows APIs in Windows Store apps. Second error App resources FAILED Branding Error Found The branding validation test encountered the following errors Image file SplashScreen.scale 200.png is a default image. Impact if not fixed Windows Store apps are expected to be complete and fully functional. Apps using the default images e.g. from templates or SDK samples present a poor user experience and cannot be easily identified in the store catalog. How to fix Replace default images with something more distinct and representative of your app. Here is the full output for further details 1.1.1.0 App Architecture x64 Kit Version 10.0.16299.15 OS Version Microsoft Windows 10 Pro (10.0.16299.0) OS Architecture x64 Deployment and launch tests PASSED Bytecode generation PASSED Background tasks cancelation handler PASSED Platform version launch PASSED App launch PASSED Crashes and hangs Package compliance test PASSED Application count PASSED App manifest PASSED Bundle manifest PASSED Package size PASSED Restricted namespace Windows security features test PASSED Binary analyzer PASSED Banned file analyzer PASSED Private code signing ... (error 1 above) App manifest resources tests PASSED ... (error 2 above) Debug configuration test PASSED Debug configuration File encoding test PASSED UTF 8 file encoding App Capabilities test PASSED Special use capabilities Windows Runtime metadata validation PASSED ExclusiveTo attribute PASSED Type location PASSED Type name case sensitivity PASSED Type name correctness PASSED General metadata correctness PASSED Properties Package sanity test PASSED Platform appropriate files PASSED Supported directory structure check Resource Usage Test PASSED WinJS background task |
0 | Optimizing data structure for my text adventure? In my text adventure I'm making, I store the story data in a hashtable (I'm using unity's javascript unity script since I'm more comfortable with the syntax than C ). The problem is, the way I structure the hashtable means that it gets incredibly bloated very quickly (I've used the same structure in all of my text adventures across multiple languages. It quickly grows to nearly 1k lines long) which makes it hard to edit in the future (especially if I need to go back to edit certain parts later on) Here's the hashtable as it's currently structured public static var story "0" "text" "", "choices" "response1" "text" "", "nextPart" "1" , "response2" "text" "", "nextPart" "2" , "response3" "text" "", "nextPart" "3" , "1" "text" "", "lastPart" "0" , "2" "text" "", "lastPart" "0" If anyone could help me optimize the structure of the hashtable that'll make it so it's more easier for me to edit it in the future, that would be great Quick information for parts that may not be self explanatory "lastPart" indicates to the hashtable parser that the player has died and the number refers to the part where they chose the response choice. "nextPart" refers to the part of the story the response leads to. |
0 | Running a scene in the background I've made 2 scenes where a room is another scene and the other is the outside of it. But whenever I do something in either scenes, and enter the other, it resets everything I did in the first one. I'm thinking of making the scene running in the background the whole time but how can I do that? |
0 | How do I reference one game object in a script attached to another? This is all in Unity, with C . I have attached a script to my player that should destroy a TreeGroup (as in a forest) whenever I press 'Q' and instantiate one when I press 'E'. Here is the code using UnityEngine using System.Collections public class DisableTrees MonoBehaviour Use this for initialization void Start () Update is called once per frame void Update () if (Input.GetKeyDown (KeyCode.A)) Disable Trees on A Keypress Debug.Log("Trees Disabled!") if (Input.GetKeyDown (KeyCode.E)) Enable Trees on E Keypress Debug.Log("Trees Enabled!") How do I access and find my 'TreeGroup' object group while script not being attached to 'TreeGroup' but my character instead and then Destroy on Q Keypress? And how do I Instantiate it? |
0 | How to Subscribe to Events from Unity's VRInput Script I am new to Unity and trying to modify the Unity tutorial Interactive 360 Sample. I want to be able to call a function when a user swipes using an Oculus Go Controller. I noticed that the VRInput script is included in the project, which seems to be able to detect swipe gestures. But where do I attach that script, and how do I subscribe to the OnSwipe event. I am currently trying by making an empty game object, and attaching the InputVR script as well as my own script called "GestureHandler" (I'm not sure whether InputVR is already attached to something else in the sample project, or whether I need to attach it at all). In my GestureHandler script I currently have the following using System.Collections using System.Collections.Generic using Interactive360.Utils using UnityEngine public class GestureHandler MonoBehaviour void onEnable() VRInput.OnSwipe HandleSwipe void onDisable() VRInput.OnSwipe HandleSwipe void HandleSwipe() Debug.Log("swipe") and currently have the following errors An object reference is required for the non static field, method, or property 'VRInput.OnSwipe' Assembly CSharp No overload for 'HandleSwipe' matches delegate 'Action lt VRInput.SwipeDirection gt ' Assembly CSharp An object reference is required for the non static field, method, or property 'VRInput.OnSwipe' Assembly CSharp No overload for 'HandleSwipe' matches delegate 'Action lt VRInput.SwipeDirection gt ' Assembly CSharp |
0 | translation and rotating at the same time and waiting before animation? I am having difficulties here. I want to move my character with the buttons and I want the character to rotate wherever he is going. Also I want to play an animation when there is no keys pressed. I am able to do that but I want the animation to play after 10 seconds of no key being pressed, and only once. Than after a movement that resets and again after 10 seconds of no key the animation plays. (The animation works but it happens right after I stop pressing a key and continuously.) IEnumerator Test() yield return new WaitForSeconds(10.0f) void Update() if (Input.GetKey(KeyCode.W)) counter Time.deltaTime transform.Translate((Vector3.forward) moveSpeed Time.deltaTime) Debug.Log("Pressing W key") if (Input.GetKey(KeyCode.S)) counter Time.deltaTime transform.Translate((Vector3.back) moveSpeed Time.deltaTime) Debug.Log("Pressing s key") if (Input.GetKey(KeyCode.A)) counter Time.deltaTime transform.Rotate(Vector3.down rotateSpeed) Debug.Log("Pressing a key") if (Input.GetKey(KeyCode.D)) counter Time.deltaTime transform.Rotate(Vector3.up rotateSpeed) Debug.Log("pressed D") if (!Input.GetMouseButton(1)) moveSpeed 20 if (!Input.anyKey) if (counter gt 2) StartCoroutine(Test()) anim.Play("Animation") counter 0 Debug.Log("A key or mouse click has been detected") |
0 | Mapping polar coordinates to cube I am trying map polar coordinates to points on a cube. I was able to map the front, back, left and right faces of the cube, but I am struggling with the top and bottom. Here is what I have lt summary gt Converts polar coordinates to uv coordinates on a cube. lt summary gt lt param name "p" gt The polar coordinate p.x longitude, p.y latitude. lt param gt lt param name "face" gt The face of the cube that p maps to. lt param gt lt returns gt The xy coordinate on the cube face. lt returns gt private Vector2 PolarToCubeFace(Vector2 p, out CubemapFace face) face CubemapFace.Unknown Vector2 result Vector2.zero float lng p.x East to West. float lat p.y North to South. if (lat gt 45 amp amp lat lt 135) Front, back, left, or right face. face (lng gt 0 amp amp lng lt 90) ? CubemapFace.PositiveZ (lng gt 90 amp amp lng lt 180) ? CubemapFace.PositiveX (lng lt 90 amp amp lng gt 180) ? CubemapFace.NegativeZ CubemapFace.NegativeX result.y (lat 45) 90f result.x mod(lng, 90) 90f else Top or bottom face. Need help here. return result |
0 | Unity get screenshots from various resolutions To upload my app to Google Play I need to provide various screenshots. Thing is, I have only one tablet, no phone and I don't feel like virtualizing a bunch of devices. Is there a way to create screenshots of different sizes? Like what would a 7" 1280X720 tablet see? |
0 | To Unity Rigidbody move like Character Controller on collision I want to a blue ball moving like a figure. in CharacterController, it was possible. but in Rigidbody, object was stucked. help me. |
0 | Unity Physics.Raycast give false positive while using layer mask I'm very new to Unity so please excuse my question if this sounds very basic to you. I'm following various tutorials and I have a small question regarding Physics.Raycast if (Input.GetButton("Fire1")) check ground hit first RaycastHit hit if (Physics.Raycast(ray, out hit, LayerMask.GetMask("Ground"))) Debug.Log(" PlayerMotion Hit" hit.collider.name " " hit.point) agent.SetDestination(hit.point) Here, even tough I expressively set the layer mask to "Ground", I still get a hit with the Player game object itself (the ground hit is working fine). I thought ok maybe I put the "Ground" layer as well on the player by mistake but I checked several times and it's not the case. I'm attaching a gif so you can see what's the issue exactly There's an easy by checking the collider.name but I still find it odd that the Raycast gives me a false positive with the player hit. Any idea what's going on ? |
0 | How to apply code of certain script to another? I have a code in my "OnCollider" script to respawn whenever the player dies and has taken an object containing tag 'Respawn'. 1st script OnCollider using System.Collections using System.Collections.Generic using UnityEngine public class OnColllider MonoBehaviour public GameObject Doorfinder public GameObject Door2 public Transform Camera public Transform target public GameObject Coin public bool collided public GameObject Playee public GameObject currentRespawn void Start() Door2 GameObject.Find ("Door0.2") Playee GameObject.Find ("Player") public void OnCollisionEnter2D(Collision2D collision) if (collision.gameObject.name "scroll") Destroy (collision.gameObject) Destroy (Doorfinder) if (collision.gameObject.tag "Fire" ) Playee.SetActive (false) if (collision.gameObject.name "PathFinder") Destroy (collision.gameObject) Destroy (Door2) if (collision.gameObject.tag "Coin") Destroy (collision.gameObject) if (collision.gameObject.tag "subVillains") Playee.SetActive (false) if (collision.gameObject.tag "Bramble") Playee.SetActive (false) Respawnable (collision) public void Respawnable (Collision2D collision) if (collision.gameObject.tag "Respawn") collided true collision.gameObject.SetActive (false) if (collided true amp amp Playee.activeInHierarchy false) transform.position currentRespawn.transform.position Playee.SetActive (true) collided false if (currentRespawn.activeInHierarchy false amp amp collision.gameObject.tag "Respawn") currentRespawn collision.gameObject 2nd Script Enemy using System.Collections using System.Collections.Generic using UnityEngine public class MaxyMory MonoBehaviour public Vector2 origin public float distance public int layerMask public float sider public Vector2 secondorigin public float bringer public float lesngther public GameObject destroy public Vector2 origination public float middle public float lengther Use this for initialization void Start () origin new Vector2 (transform.position.x bringer, transform.position.y sider) origination new Vector2 (transform.position.x bringer, transform.position.y middle) secondorigin new Vector2 (transform.position.x bringer, transform.position.y lengther) Update is called once per frame public void Update(GameObject Playee) Debug.DrawRay (origin, Vector2.right distance, Color.red) Debug.DrawRay (secondorigin, Vector2.right distance, Color.cyan) Debug.DrawRay (origination, Vector2.right (distance 30f), Color.gray) RaycastHit2D hit Physics2D.Raycast (origin, Vector2.right, distance) RaycastHit2D anotherhit Physics2D.Raycast (secondorigin, Vector2.right, distance) RaycastHit2D checker Physics2D.Raycast (origination, Vector2.right, distance 2f) if (hit.collider.tag "Player" anotherhit.collider.tag "Player") Playee.SetActive (false) OnCollider is attached to the player while the enemy script is attached to the enemy itself. |
0 | Unity3D AI follow player script for prefab enemy? So I am having an issue, I have an enemy prefab that is created when the new wave happens(think of Nazi Zombies from Call of Duty, same system) but every script I have found that deals with ai following player always involves a public transform variable. The issue is that the object I put in that variable in the inspector does not save with the prefab, rendering the script useless. Is there anyway I can get the enemy prefab when the enemy spawns to follow the player? He is a script I tried and failed due to the issue The target player public Transform player In what time will the enemy complete the journey between its position and the players position public float smoothTime 10.0f Vector3 used to store the velocity of the enemy private Vector3 smoothVelocity Vector3.zero private void Start() Call every frame void Update() Look at the player transform.LookAt(player) Move the enemy towards the player with smoothdamp transform.position Vector3.SmoothDamp(transform.position, player.position, ref smoothVelocity, smoothTime) Time.deltaTime |
0 | How to model walkable houses for Unity I created a house in blender which is a big cube with the upper face intended and pulled down back to the ground. The floors are other boxes and windows and doors are cut out using a boolean modifier. The problem is that the character controller from the Unity standard assets seems to get stuck between the floors and the walls. I have seen that counter strike maps are mostly not made out of cubes but a lot of planes put together. Is that the proper way to model walkable buildings? |
0 | Finding if 2 polygons intersect using clipper library After realising my code was pretty inefficient at checking for polygon overlaps, I've turned to a mentioned library Clipper but finding it difficult to know hot to use it for this operation. I am using unity Vector2 for my shape descriptions Square Vector2 square new Vector2 new Vector2(0,0), new Vector2(1,0), new Vector2(1,1), new Vector2(0,1) I want to be able to do the above boolean comparison of 2 shapes. If anyone knows Clipper well, what methods can I use to do this check? I've recently tried the following but the result is always true even when the test shapes are completely separate from each other public bool CheckForOverLaps(Vector2 shape1, Vector2 shape2) List lt IntPoint gt shape1IntPoints Vector2ArrayToListIntPoint (shape1) List lt IntPoint gt shape2IntPoints Vector2ArrayToListIntPoint (shape2) List lt List lt IntPoint gt gt solution new List lt List lt IntPoint gt gt () c.AddPath (shape1IntPoints, PolyType.ptSubject, true) c.AddPath (shape2IntPoints, PolyType.ptClip, true) c.Execute (ClipType.ctIntersection, solution, PolyFillType.pftNonZero, PolyFillType.pftNonZero) return solution.Count ! 0 private List lt IntPoint gt Vector2ArrayToListIntPoint (Vector2 shape) List lt IntPoint gt list new List lt IntPoint gt () foreach (Vector2 v in shape) list.Add (new IntPoint (v.x, v.y)) return list And the tests Square Vector2 square new Vector2 new Vector2(0,0), new Vector2(2,0), new Vector2(2,2), new Vector2(0,2) Square Vector2 square2 new Vector2 new Vector2 (1, 1), new Vector2 (3, 1), new Vector2 (3, 3), new Vector2 (1, 3) Square Vector2 square3 new Vector2 new Vector2 (2, 0), new Vector2 (4, 0), new Vector2 (4, 2), new Vector2 (2, 2) Square Vector2 square4 new Vector2 new Vector2 (4, 0), new Vector2 (6, 0), new Vector2 (6, 2), new Vector2 (4, 2) Assert.IsTrue(tc.CheckForOverLaps(square,square2)) Assert.IsFalse(tc.CheckForOverLaps(square,square3)) Assert.IsFalse(tc.CheckForOverLaps(square,square4)) Many thanks. |
0 | Execute a function for ten seconds and disable it for two seconds I have a particular function which I am calling in Update function. For the first ten seconds, the function should get called in Update function, then it should get disabled for next two seconds, then again enable it for next ten seconds. This cycle should keep repeating? How can I execute it? |
0 | Why does the object spawns only on client? In my game I have an object, let say food, that whoever consumes it, that player will spawn one more element. I am checking collision in Update. The following code is working fine on server side, but the object is not spawning. Although, it is spawning on local client but it is not updating on server. Here is my code This function is called on Update private void CheckForFood(Vector3 snakePartPosToBeInitialize,Vector3 headPos) if( food ! null) if ( food.transform.position headPos) UiControllerCS.UI.showScore() GameObject obj Instantiate(snakePart, snakePartPosToBeInitialize, Quaternion.identity) as GameObject currPartOfSnake 1 obj.name quot quot currPartOfSnake obj.transform.parent gameObject.transform tail.Add(obj) NetworkServer.SpawnWithClientAuthority(obj , connectionToClient) I am getting the following error SpawnObject for 1 (UnityEngine.GameObject), NetworkServer is not active. Cannot spawn objects without an active server. |
0 | Apply a special effect to a scene area My 2D game has a second camera on the scene that renders an upside down image of the scene and distorts it, giving the effect of water reflection. I render this camera first, and on top of it I render the main camera. This is working correctly as expected, however, I want to improve it's performance by performing this process in small sections of the scene instead of the whole screen. I created a trigger to detect which items should be turned upside down and rendered. How can I turn these items and distort them as I did with the whole scene, but only to the GameObjects detected inside the trigger? Note I can't assign them to a layer since the layer is already in use. |
0 | Unity remote not recognising my phone? I made a new project with the Android module installed, which works fine as I can build and run it on my phone when connected to my computer via USB, and yet can't get Unity Remote to work. Edit Project Settings Editor Device won't display my phone's name. I tried several internet solutions I found (such as closing and opening again both Unity and Unity Remote or enabling PTP transfer) and none worked. Any ideas on what could be going on? |
0 | Creating outline from a collection of points following the concavity I am trying to create an outline from a collection of points. I found this solution for Convex Hull. I specifically picked this implementation https en.wikibooks.org wiki Algorithm Implementation Geometry Convex hull Monotone chain Edit I can't find an algorithm that will find the concavity of the region specified in green. The yellow line is the Hull from the algorithm amove I have the point is defined as Serializable public struct Point IComparable lt Point gt , IEquatable lt Point gt public int X public int Y public static int Cross(Point o, Point a, Point b) return (a.X o.X) (b.Y o.Y) (a.Y o.Y) (b.X o.X) Here is the implementation of the algorithm public static List lt Point gt ConvexHull(List lt Point gt points) if (points null points.Count lt 3) return points var size points.Count var k 0 var hull new Point 2 size points.Sort() build lower hull for (int i 0 i lt size i) while (k gt 2 amp amp Point.Cross(hull k 2 , hull k 1 , points i ) lt 0) k hull k points i build upper hull for (int i size 1, t k 1 i gt 0 i) while (k gt t amp amp Point.Cross(hull k 2 , hull k 1 , points i 1 ) lt 0) k hull k points i 1 var result new List lt Point gt (hull) if (k gt 1) result.Resize(k 1) remove non hull vertices after k remove k 1 which is a duplicate return result |
0 | How can I convert a string to quaternion? private GameObject GetObjectFromFile(string path) GameObject newobj new GameObject() string text new string 3 if (File.Exists(path)) text File.ReadAllLines(path) foreach (string s in text) text s.Split(' ') break var parent text 0 var localPosition StringToVector3(text 1 ) var localRotation StringToVector3(text 2 ) var localScale StringToVector3(text 3 ) newobj.transform.localPosition localPosition newobj.transform.localRotation localRotation newobj.transform.localScale localScale return newobj public static Vector3 StringToVector3(string sVector) Remove the parentheses if (sVector.StartsWith("(") amp amp sVector.EndsWith(")")) sVector sVector.Substring(1, sVector.Length 2) split the items string sArray sVector.Split(',') store as a Vector3 Vector3 result new Vector3( float.Parse(sArray 0 ), float.Parse(sArray 1 ), float.Parse(sArray 2 )) return result It's converting fine the localPosition and localScale but the localRotation is a quaternion and not vector3. This is the text file format I'm reading from Main Camera (UnityEngine.Transform) (297.7, 5.1, 228.5) (0.0, 0.0, 0.0, 1.0) (1.0, 1.0, 1.0) The part (0.0, 0.0, 0.0, 1.0) is the rotation. |
0 | Projecting texture from an arbitrary position I'm trying to write a surface shader (not a projector) to project a texture to a surface in a very similar way of what projectors do. Currently I can easily obtain a shader that uses screenspace as UV float2 screenUV IN.screenPos.xy IN.screenPos.w What I'm trying to achieve is to have an arbitrary plane to project the texture over the mesh that uses the shader. I'm checking some resource online like https en.wikibooks.org wiki Cg Programming Unity Cookies but this is strongly related to light space. My main doubt is how can I generate the UV coordinates from another plane? should I define somehow plane sizes or is it enough to define its position? |
0 | My money will only save for one game run I am trying to make a money system my problem is that the money value only saves for 1 game run then the value returns to 0. Here is my code. What should I do. using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class Money variables public Text cash Use this for initialization void Start () if (counter lt 9 amp amp counter gt 1) money money 2 PlayerPrefs.GetInt("money", money) PlayerPrefs.SetInt("money", money) else if (counter gt 10 amp amp counter lt 20) money money 5 PlayerPrefs.GetInt("money", money) PlayerPrefs.SetInt("money", money) else if (counter gt 21 amp amp counter lt 30) money money 15 PlayerPrefs.GetInt("money", money) PlayerPrefs.SetInt("money", money) else if (counter gt 31 amp amp counter lt 40) money money 25 PlayerPrefs.GetInt("money", money) PlayerPrefs.SetInt("money", money) else if (counter gt 41 amp amp counter lt 70) money money 50 PlayerPrefs.GetInt("money", money) PlayerPrefs.SetInt("money", money) else if (counter gt 71 amp amp counter lt 100) money money 75 PlayerPrefs.GetInt("money", money) PlayerPrefs.SetInt("money", money) else if (counter gt 101 amp amp counter lt 200) money money 100 PlayerPrefs.GetInt("money", money) PlayerPrefs.SetInt("money", money) else if (counter gt 201) money money 150 PlayerPrefs.GetInt("money", money) PlayerPrefs.SetInt("money", money) cash.text "Credits " PlayerPrefs.GetInt("money", money) |
0 | How to calculate FPS and what factors affect FPS? In this case, FPS means Frames Per Second and that means the number of frames that graphic hardware render in one second. I'm wondering what kind of stuffs could affect FPS? So, for some tests I created a simple scene in Unity with some cubes and capsules and then create a empty game object and then add this c code to it public class FPSReport MonoBehaviour public double Fps void Update () Fps 1.0 Time.deltaTime I think it can tell me the FPS. When I played it it worked but it wasn't more than 30. I was saw a lot of games that their fps was normally on 150. Is this fps rate ok? If I add more objects, textures, animations , etc ... to my scene. What happen to my fps? Could it attain zero? and If it attain zero, what is the meaning of a zero FPS (the hardware stopped working?!)? |
0 | How to disable collider2D when another gameobject is on top of it Each black colored square has a BoxCollider2D. How can I disable the collider after I put another game object on top of it? Here is the sample output |
0 | Alternative solutions to applying an overly large and detailed texture to a mesh I have a very large spherical mesh in my Unity scene (the earth), to which one very large texture is applied (a map of the earth). Now it just so happens that Unity's max texture size (8192 pixels I believe) is not enough to capture the details I need on this huge mesh. What's the proper way to deal with this situation in Unity? That is, not only overriding the 8192 pixels limitations (although that would be nice as a temporary solution), but also making sure the overhead won't become unbearable... Is there a way to dynamically stream higher quality sections of textures as the camera gets closer to that specific part of the mesh? Additionally, I see the Granite add on (http graphinesoftware.com products granite for unity) seems to do just this (if I understood it well), but it's only for Windows, and I'm developing on a Mac. Is there any other adding out there? |
0 | How to know which child collider triggered in parent? I have parent object with 3 children. Each children has one collider (BoxColliders actually) marked as triggers each one. I want to know in a OnTriggerEnter on the parent side which collider was hit. Similar to this question How can I determine which Trigger is hit? But for 3D Colliders (not 2d). As you can see in the accepted answer they used Collider2D.IsTouching but it doesn't seem to exist any analogue method for a 3D Collider If is not possible, what other solutions are there? What would be the recommended way? I would like to avoid the overhead from methods like CompareTag and SendMessage if possible. http answers.unity.com answers 1206114 view.html |
0 | How can I detect a Gameobject touching another gameObject without using collider2D's? I have fish gameObjects that have colliders2D so that I can click and move them. I added fish food with Collider2D's but it was hard for me to click on the fish. After I disabled the fish food collider2D it was easier to click on the fish. Is there an alternative when detecting two gameObjeccts without colliders? |
0 | added a pipeline and now my terrain is pink...how do I fix it? I needed to add a pipeline to my world because an asset required it. I was following the directions here. Since adding the pipeline, my terrain is pink. I found a references that stated the pipelines do not support terrain, there are problems with more than 4 textures (I have 1) etc...but this was a year ago. Is this fixable or am I at choice between no pipeline or buying pipeline enabled terrain (and hence redoing all of my scenes)? What is the solution? Thnx Matt |
0 | Unity using WWW to download image from web. Not working from my own website, but does from other urls I have this script attached to a RawImage file in my games UI public class DownloadImage MonoBehaviour string url "http megabrogames.rf.gd pic.jpg" string url "https i.imgur.com xBSyvRx.jpg" IEnumerator Start () WWW www new WWW(url) yield return www GetComponent lt RawImage gt ().texture www.texture Both jpg files are the same. One I uploaded to Imgur, this works. The other is on my own website. The url to my website works fine, I have checked in on two computers and several browsers. All I get is the red question mark. But if I uncomment the other one instead it all works perfectly. My problem is that I have hard coded the url into the game, and I want to change the image each week. It has to be the same URL for that to work, but i think with Imgur it will auto assign whatever url it feels like. thanks for any help |
0 | What is the logic behind the 'Loading' scenes in games? I'm making my first game, it's a tower defense type of game, using Unity game engine and taking Fieldrunners as a reference. I would like to know more about the functionality behind 'Loading' scenes in games. Until now I am instantiating creating objects at run time and I'm not facing any delay or similar issues doing so. So what are 'Loading' scenes in other games used for? Is there some functionality or instantiation of specific objects for the next round or stage? If yes why do I need them if I'm not getting any delays? |
0 | Raycasting from an object to the center of the screen (crosshair) without clipping through objects Am trying to learn about Raycasting, and I thought I would start with something simple, and that was a laser that would come out of an object (think laser pointer in your hand) and always go to the crosshair. Using ViewportToWorldPoint I found it easy to cast a ray from the center of the camera, but this had an issue as you can see in this GIF below. The line would clip through because the ray was coming from the center, not off to the side where the laser pointer would be. Am not sure how to solve this. void Update() Vector3 ray Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0f)) line.SetPosition(0, transform.position) RaycastHit hit if(Physics.Raycast(ray, Camera.main.transform.forward, out hit, raylength)) if(hit.collider ! null) line.SetPosition(1, hit.point) else Vector3 pos line.GetPosition(0) line.SetPosition(1, ray (Camera.main.transform.forward raylength)) The closest thing I could find that I am trying to replicate for this exercise is the No Man's Sky mining tool |
0 | Lower WebCamTexture dimension without requesting Handling image with high resolution dimension can cause heavy lag in low spec computer . So i need to lower the dimension of the image to make it less lag for processing . I know i can do it with WebCamTexture.request(width height) , but if the camera does not support low dimension image , the result image dimension will be still big . I've tried to convert it to Texture2D using WebCamTexture.GetPixels() and uses lower width and height for the Texture2D , but it breaks the image and the result was unexpected . I also have tried to set the WebCamTexture to an object , and get that object captured by in game camera , and resize the image that was captured by the camera , but then it means the high dimension image is doubled (WebCamTexture and image from the in game Camera) and doubled the lag than just using WebCamTexture . Can anyone here help me please ? i will upvote for any attempt to help . |
0 | Unity using "as" vs "GetComponent()" Hello im new to unity and im learning raycast right now , after checking the documentation here https docs.unity3d.com ScriptReference RaycastHit triangleIndex.html , i got something that's confusing me , what is the difference between MeshCollider themeshhit thehit.collider as MeshCollider if (themeshhit null) Debug.Log (" themeshhit null ! ") and MeshCollider themeshhittwo thehit.collider.gameObject.GetComponent lt MeshCollider gt () if (themeshhittwo null) Debug.Log (" themeshhittwo null ! ") Both method is working correctly , but i want to know what is the difference between them , and i also want to know which one is better if comparing against speed , compatibility , and ability . Edit variable thehit is look similar to this RaycastHit thehit |
0 | What does " get set " in Unity mean? I am coming back again into hobby game development after about 6 months away. I'm just trying to learn some kind of basic things again. I'm at the very start of making a very simple boxing management simulator. Later, I will be trying to re learn using databases and might ask for more help. But for now, I'm making a Boxer class which will hold all the data on each boxer (eg. Name, height, number of wins, punch power etc etc). I've used private variables for those and then have made my own methods for each variable called Getxyz(). I have seen people doing things like 'public int xyz Get() ' but i dont understand how that would work. Is the way I'm doing ok (it does seem long winded to me) or should I investigate these Getter Setters some more? Here's what I am doing right now public class Boxer MonoBehaviour generic boxer details int id string nameA, nameB int weight int height float age float reach career info int wins, loses, draws, winsByKO boxing attributes stats float power, speed, agility, koPunch, stamina, toughness public int GetId() return id public string GetNameA() return nameA public string GetNameB() return nameB |
0 | How to rotate object not from it's center point but from it's another point? I am new in unity and I am developing a game where I want to rotate my object I try this code for it. if(Input.GetMouseButton(0)) if(Input.GetMouseButtonDown(0)) LastMousePosition Input.mousePosition else if(LastMousePosition.y gt 112) Bow.Rotate(Vector3.up (Input.mousePosition.y LastMousePosition.y)) else if(LastMousePosition.y lt 112) Bow.Rotate(Vector3.down (Input.mousePosition.y LastMousePosition.y)) LastMousePosition Input.mousePosition It works fine for me but my object is rotate from It's center point and I want to rotate it from another point can any one help me with this? |
0 | Unity, OnMouseOver blocked by another gameobject with a collider in front of it I have two gameobjects, both with 2D colliders. One of them can be behind the other, and because of this its OnMouseOver can be blocked from firing as the GameObject in front blocks it from triggering. What is a way around this? I really like the ease of using OnMouseOver, and would rather not use raycastAll. Asked this question on SO, maybe it should be asked here. |
0 | Imposters in Unity How to set which color is used as 'transparent' in the RenderTexture? I'm still working at making imposters for my Unity scenes. Here I am attempting to make a large block of stadium seating, using the one seat mesh as shown. I'll try to explain in full what Ive done so far Imported 3d mesh of seat Created RenderTexture 'seat' (default format R8G8B8A8 UNORM) Added new Orthographic camera in front of seat. (settings Clear Flags Solid Color TargetTexture 'seat' Created some quads and aligned them so I can see the textured side. Gave the quads a new material 'seat'. I've gone through many of the settings in the Material and other places changed many things here and there such as 'transparent' or 'cutout' and lots of the other settings but cannot get rid of the magenta color in the seating textures I created. Also tried making that color alpha 0 but it had no effect. And tried various colors as transparent (magenta, white, black). Am I doing this completely wrong? Hopefully I am just missing some small setting. Ideally somewhere I can just set the magenta color to mean transparent pixels. Really do need help here honestly have been trying very hard to achieve this alone but not getting anywhere fast. |
0 | Every Item is colliding but 1 In my game I have a BULLET, MOONS, STARS, and A SHIP. I shoot bullets from the ship and hit stars or moons and collisions occur. Yet when a moon runs into my ship there is no detection even though I set the a Collider for 2D on both of them. void OnCollisionEnter2D (Collision2D col) Debug.Log (this.transform.tag) moon hit ship not printing Debug.Log (col.transform.tag) only bullet hit moons and stars Heres a quick snippet https i.gyazo.com acc0bbf5d2aab994db3a6598bfd206aa.mp4 |
0 | Google play services error DEBUG Application is pausing, which disconnects the RTMP client I am having this issue from past day with Google Play Services amp Unity. What happens is, when I install app directly ot device via Unity, the Google Play Services work fine but when I upload it as beta to play store console and install it via that then it starts to give " DEBUG Application is pausing, which disconnects the RTMP client" error. I have a proper SHA1 key. |
0 | NullReferenceException when importing model This error most certainly is not caused by an error in my Script. I don't know where it came from, I don't know why it's here and I don't understand what problems it causes because everything seems to work just fine. But I've been getting this error for quite a while now every single time I run the Game Engine |
0 | How to limit my scoreboard to 100 top Score then adding the number list? so I want to make 100 top scorers on my leaderboard but I don't know how to make a number list, what I mean is when the user is top 1 so number list 1 and so on so here the leaderboard script public IEnumerator LoadScoreboardData() var DBTask DBreference.Child( quot users quot ).OrderByChild( quot highscore quot ).LimitToLast(100).GetValueAsync() yield return new WaitUntil(predicate () gt DBTask.IsCompleted) if (DBTask.Exception ! null) Debug.LogWarning(message quot Failed to register task with DBTask.Exception quot ) else Data has been retrieved DataSnapshot snapshot DBTask.Result Destroy any existing scoreboard elements foreach (Transform child in MainMenuUI.instance.scoreboardContent.transform) Destroy(child.gameObject) Loop through every users UID foreach (DataSnapshot childSnapshot in snapshot.Children.Reverse lt DataSnapshot gt ()) string username childSnapshot.Child( quot username quot ).Value.ToString() int highscore int.Parse(childSnapshot.Child( quot highscore quot ).Value.ToString()) Instantiate new scoreboard elements GameObject scoreboardElement Instantiate( MainMenuUI.instance.scoreElement, MainMenuUI.instance.scoreboardContent) scoreboardElement.GetComponent lt ScoreElementContent gt ().NewScoreElement(username, highscore) Go to scoreboard screen MainMenuUI.instance.leaderboardPanel.SetActive(true) as you can see there is no number list just order by highest score. |
0 | Everything is set to Bounciness 0 Why am I still bouncing? I am creating a platformer where rather than manipulating the character to get them from the beginning of the level to the end, you manipulate the world. Thus, when you want to make the character 'jump' over a gap, you actually use the land like a slingshot and 'fling' them. This is all working well and good save for one thing whenever I pull my land down and my player falls into it again, it begins to bounce aggressively so! I have made EVERYTHING out of a new physics material with 0 bounce, and I set my default physics to 0 bounce. My player is a rigidbody2D that is moving itself along on top of other rigid bodies. What gives? Why, even though EVERYTHING is set to 'no bouncing allowed' does my game turn into a bouncy house whenever i start to play? EDIT Here is a video of the behavior FlingyJump Bouncing Issues EDIT I have noticed a correlation to the bounce occurring and the spring being active. It have noticed that two things are happening 1) The spring is for some reason transferring force through to the ground piece while being stretched out. 2) The player is bouncing before even ever hitting the ground. I don't know quite how that is possible but it seems like as soon as it is enters the original position of the rigidbody2D for the ground piece it bounces. |
0 | How to destroy object after animation I've made an object and when the player has pick it up, rise it up and stop it out of screen. But because you can see the shadow of that object, I will destroy it after the animation has played. But how can I do this whit Unity and C ? Just destroy is just like this Destroy(gameobject) and start an animation like this private Animator anim global variable anim GetComponent lt Animator gt () in start() methode anim.SetTrigger("Picked") in other methode |
0 | Can't interact with anything in UI canvas, although it was working previously I'm working on a menu with several buttons and input fields. For a while everything was working fine, but suddenly every button and input field is not reacting to being clicked on, as if everything's been disabled. This problem is only occurring in one of my scenes. My canvas has a graphic raycaster and my buttons have methods attached to them. |
0 | How do I calculate a line segment that is a certain number of degrees from another line segment? I have a line segment that is at an arbitrary angle in 3D space. I want to (in code) draw another line that shares an end point with the first line and has an angle of arbitrary degrees between them. The second line will partially overlap the first in the XZ plane. |
0 | Animated lighting in amusement parks What is the best way to handle animated lights on rides in a night time amusement park scene? Is there a better way that doing lots of emission lights? At the moment I have been using emission lights, but there could be a lot of them in a park (some are just static lights) and I would also like to animate some of them on some rides. Best example I could find was from GTA 5 Video https youtu.be zVj8D0lqgl4?t 146 |
0 | Does Animator.SetBool take precedence over Animator.SetTrigger in Unity's Animator? I've got an Animator with transitions from Idle to Walk or Dash. Walk requires isGrounded to be true and a float MoveX to be greater than .2. The Dash animation requires Dash trigger is returned. In my code, when the shift key is pressed I call anim.SetTrigger("Dash"), if a Walk key is pressed, I set anim.SetBool("Idle") to false and begin increasing MoveX. The problem I'm noticing is that when I play, and hit the dash button, it first starts walking and then after playing that animation it will then perform the dash animation. Looking in the animator as this is happening, it's clear that the walk animation plays in full before moving to the dash animation. What can I do to give priority to the Dash animation when that button is pressed? |
0 | How to apply a script to multiple Objects in Unity? In Unity, I've almost 200 or more objects. I wish to apply single script to all those objects. I'm a beginner amp learning scripts in Unity. Edit At the time of editing the scene itself. |
0 | Deleting fewest Navmesh Obstacles when no valid path is found So I'm building a Tower Defence, with mazing (i.e. the player can place towers to make the mobs take a longer route to there destination.) I'm using Unity's Navmesh system. Each Enemy unit has a Navmesh Agent component. And each Tower has a Navmesh Obstacle component. The Path finding is working Perfectly. However (as expected) when the play completely blocks off all routes to the Agent's Destination, the agent simply moves to the spot closest to the destination that it can get to and sits there. What i need, is to detect when that happens... Some kindof NoValidRoute() or something, I haven't been able to dig anything up in the Unity documentation or from google Searches. Once i have that, I need to determin which Navmesh Obstacles need to be destroyed to open the shortest route possible with the fewest number of Obstacles destroyed. (i.e. if a path can be opened with only 1 tower destroyed which tower would give me the shortest route.) I'm finding a serious lack of any information on this subject.. as far as i can tell no one has even tried to do this, or asked for help doing something like this. (at least not with Unity's Nevmesh.) I think A is a little(and by little i Mean LOTS) outside of my skill to implement at present. Thanks In advance |
0 | Why does Unity heavily blur edges of a single cube despite 8x antialisaing I was messing around a random project and everything was working perfectly, when all of a sudden jagged edges appeared on all objects. I've been trying to resolve this issue for the past two dails, only to no avail. I have tried changing various settings, when at last I've uninstalled unity and removed all projects. After re installing it, however, the problem still persists What I've tried changing settings in Nvidia Control Panel (for example, settingantialisaing mode to application controlled) changing the Quality settings inside Unity removing any normal texture maps changing metallic and smooothness of the material and removing specular highlights reinstalling Unity These pictures depict current settings object properties Properties of material added to the cube Camera properties Quality settings Graphics settings |
0 | How to create a high score in Unity from a Time.deltatime float? When I play my game, it sets my score to 0 and does not change, no matter how high my float gets. using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class highscore MonoBehaviour public Text Highscore void Start () Highscore.text PlayerPrefs.GetFloat ("Highscore", 0).ToString() This is where the next page starts using UnityEngine using UnityEngine.UI public class Score MonoBehaviour public Text ScoreText public float playerScore 0 void Update () playerScore Time.deltaTime 10 ScoreText.text playerScore.ToString("0") private void OnCollisionEnter (Collision collisionInfo) if (collisionInfo.collider.tag "Obstacle") PlayerPrefs.SetFloat ("Highscore", playerScore) |
0 | How to handle data for a competitive multiplayer games I am kinda new to Multiplayer Games and I am really wondering how I should handle my data Should each player send and update their data to the database (server) everytime one of their essential variables changes (like health or ingame currencies), or should they save the data as long as the game is running and then update the data all at once at the end of, lets say, each round? I was thinking about using Firebase and Unity and here's a scenario Let's say 2 players connect to a game. Then one of them gets damage and the other one gets gold. Does the data change get sent to the FireBase Database immediatly or should I just update everything when the round ends they disconnect? |
0 | Rendering Problems(Artifacts, Flickering) with the Mirage Solo VR Headset Im getting some strange flickering artifacts when testing on device (Mirage solo), this problem occurs on Unity 2018.3.2 and Unity 2019.1.2. Its not happening on other devices such as the OculusGo, Google Pixel, Samsung s7,s9. It seems to be only occuring on devices that use Qualcomm Adreno 540 GPU. Has anyone else encountered anything like this if so, did you fix it and how? The Environment is using a custom shader, the robot character is simply using a unity standard shader and there is a hologram at the side(right) which is using a custom shader. Hardware Snapdragon 835 SoC Qualcomm Adreno 540 GPU Video https streamable.com Screenshots Bad Good |
0 | Bright lights produce strange artifacts on Android I'm testing lighting on Android and I'm getting strange artifacts when the light is increased. I'm not sure if this is normal with Unity or a setting somewhere is unchecked. The only light in my scene is a spot light. I have to increase the brightness of it so that it illuminates everything in the scene properly. On Windows 10 (in the editor), it displays just fine. You can turn the brightness up all day long and everything will just appear whiter. On Android, however, once you reach a certain threshold (a really low threshold), the colors turn to an abrupt magenta, then dark cyan, and eventually black. Because I'm using a spot light, these colors appear as a radial gradient. Here's what I've tried so far Turning the brightness down. Unfortunately, I have to decrease it a lot to avoid the artifacts meaning my scene doesn't get illuminated in the way that I need it to be. Changing Lightmapper from Enlighten to Progressive in the Lighting window. But what I think this actually indicates is compression and so is unrelated. Not specifying a Skybox material and using Custom environment reflections. Tweaking Graphic settings for each tier (I have double checked HDR is enabled both here and on the camera present in each scene). Switching to Linear color space (I was originally using Gamma). The idea was maybe the color space was too small so really, really bright colors couldn't be represented however, it is my understanding that Gamma is much larger than Linear so I'm admittedly confused. I have Googled this issue quite a bit and all I get are issues with emissive materials not emitting light and other unrelated light issues. Here is what my scene looks like when a spot light faces a rectangular mesh. When the threshold is exceed initially, it looks like this If you continue to increase the Intensity, it eventually looks like this Of course, the exact colors you see vary based on the actual color of the mesh being illuminated. In the pictures above, the mesh is supposed to be a medium dark green. Could this be a color space issue? Perhaps a device limitation? My device isn't exactly a super computer, but it isn't bottom grade either. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.