_id
int64
0
49
text
stringlengths
71
4.19k
0
How can I combine my scrolling effect with the vertex lit shader? I want my shader to work in both Forward and VertexLit rendering modes. I'd written a texture scrolling shader, but I also want to consider lighting which is produced by Vertex lit shader. I can't add my effect directly in the vertex lit shader, so I'd created 2 passes the lighting one and the effect one. Here's my code now SubShader Tags "RenderType" "Opaque" "LightingMode" "Vertex" Pass Name "Hardware lighting pass" Tags "LightingMode" "Vertex" Zwrite On Cull Back Material Diffuse Color Lighting On At the second pass we'we turned the multiplicative blending on to combine our texture effect with the ightin that has been couputed at the previous pass. Pass Name "Effect applying pass" Tags "LightingMode" "Vertex" If you're change this, you must then change the light calculation algorithm Blend One DstColor Lighting Off Cull Back CGPROGRAM pragma vertex vert pragma fragment frag texture samplers uniform sampler2D MainTex uniform sampler2D AlphaMask uniform sampler2D ManaTexture uniform sampler2D Noise float values uniform float ManaFloatSpeed uniform float ShinessSpeed struct VertexInput float4 pos POSITION0 float4 col COLOR0 float4 uv TEXCOORD0 struct FragmentInput float4 pos POSITION0 float4 col COLOR0 half2 uv TEXCOORD0 In the vertex shader we're just applied MVP transform to our object FragmentInput vert (VertexInput i) FragmentInput o o.pos mul(UNITY MATRIX MVP, i.pos) o.uv i.uv.xy o.col i.col return o 1) Sample our fancy texture to get the pixel color 2) Get the color value of scrolled pixel of the noise texture 3) Set the alpha channel of an output color value to prevent glow at the textured areas half4 frag(FragmentInput i) COLOR0 float4 col i.col tex2D( MainTex, i.uv) Now reading from the separate mask, later it will be col.a by default (this instruction will desappear) col.a tex2D( AlphaMask, i.uv).r Epsilon to prevent dx9 11, and GLES tolerance pass (not 0.0f) if(col.a gt .0001f) Sample two textures and get the value from the alpla layer float4 tl1 tex2D( ManaTexture, float2(i.uv.x, i.uv.y ( Time.y ManaFloatSpeed))) float4 tl2 tex2D( ManaTexture, float2(i.uv.x, i.uv.y ( Time.y ( ManaFloatSpeed 2)))) float alphaValue tex2D( Noise, float2((i.uv.x Time.y ShinessSpeed), (i.uv.y Time.x))).r return half4((tl1 tl2).rgb, alphaValue) else return col ENDCG The problem is... Yep, 2 passes, which is extremely undesirable. How can I calculate vertex lit lighting and apply my effect in the single pass?
0
Rotate meshes with different pivots, equality If I have multiple equal meshes but with different pivots and I make a rotation on the first, is there a way to replicate this rotation to all meshes using a rotation Matrix? For example, if I have a cube, one with it's pivot in the center and another with the pivot outside of the mesh, how can I rotate the first one 90 degrees on the X axis and use it's rotation Matrix to have the second model rotate on itself and not on his pivot? Assuming that when I pass on the rotation matrix to other meshes I can't pass the vector of the pivot, is this possible?
0
Why the rotation using the Coroutine is rotating but the object is in slant ? and how to rotate it with Coroutine non stop? using System.Collections using System.Collections.Generic using UnityEngine public class Spin MonoBehaviour public Vector3 targetRotation public float duration public bool spinInUpdate false Start is called before the first frame update void Start() if (spinInUpdate false) StartCoroutine(LerpFunction(Quaternion.Euler(targetRotation), duration)) Update is called once per frame void Update() if (spinInUpdate true) transform.Rotate(new Vector3(0, 1, 0)) IEnumerator LerpFunction(Quaternion endValue, float duration) float time 0 Quaternion startValue transform.rotation while (time lt duration) transform.rotation Quaternion.Lerp(startValue, endValue, time duration) time Time.deltaTime yield return null transform.rotation endValue slant I mean this is how it's rotating with the Coroutine the small cube that rotate is in slant When using the Update way it's rotating fine and this is how it should rotating also with the Coroutine for example on the X only The small cube when rotating either in update or in the Coroutine should not be slant. but it's slant in the Coroutine. And how can I add a speed factor to the Update to control the rotation in the Update in case using the Update ? About controlling the speed in the Update I just added a global float variable and in the Update transform.Rotate(new Vector3(0, Time.deltaTime rotationSpeed, 0)) and it's working for the speed.
0
Player losing alignment with tilemap after moving I'm using an isometric tilemap(2 1) and I can't figure out how to make grid based movement on it's surface. I managed to get a code working for the grid based movement, moving my character with 0.5 along the Y axis and 0.86 ( sqrt(3) 2 ) along the X axis since I imagine it should work as if they are diamonds with the side of 1 unit, but it doesn't align with the center of the next tile. Here is my movement code using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.Assertions.Must public class Movement MonoBehaviour Vector3 pos For movement float speed 5f Speed of movement public float x 0.86f public float y 0.5f void Start() pos transform.position Take the initial position void FixedUpdate() if (Input.GetKey(KeyCode.A) amp amp transform.position pos) Left pos Vector3.left pos new Vector3( 0.86f, 0.5f, 0) if (Input.GetKey(KeyCode.D) amp amp transform.position pos) Right pos Vector3.right pos new Vector3(0.86f, 0.5f, 0) miscare in diagonala if (Input.GetKey(KeyCode.W) amp amp transform.position pos) Up pos Vector3.up pos new Vector3(0.86f, 0.5f, 0) if (Input.GetKey(KeyCode.S) amp amp transform.position pos) Down pos Vector3.down pos new Vector3( 0.86f, 0.5f, 0) transform.position Vector3.MoveTowards(transform.position, pos, Time.fixedDeltaTime speed) Move there
0
Make non sprite render in front of sprite How do I make the non sprite (BasicSpellProjectile) render in front of the sprite (Tower 2)? Note The camera is located at z 10. The z positioning apparently doesn't do anything, and I am unable to set the sorting layer order of the non sprite as there isn't one such option.
0
How to move bezier curve points along circle to form a symmetric curve at center From the image below, A is an open bezier curve with it's points positioned to represent a circle. AP3 and AP1 have the same position. From B, How can I move the points (AP1 and AP3 along the bigger circle of radius r whiles the CP's reduce in length as CP1 and CP4 also rotate) till they form a symmetric bezier curve at the center of the bigger circle marked as the red curve?
0
Gfx.WaitForPresent performance issue I am making a 2D mobile game and it runs really well (60 fps) on my phone. However, in some cases the performance goes down drastically to the point where it runs at 20 fps or even less. It happens at random times so I can't pinpoint what is causing this. During the performance decrease Gfx.WaitForPresent appears in my profiler which eats a lot of power. I am aware that this might be because of Vsync being turned on, but I have it disabled, along with shadows, AA and everything else that absolutely kills mobile performance. What else can be the problem? My game relies heavily on good performance for gameplay so this needs to be resolved ASAP. Edit I also noticed that the GPU stays at 0 ms which is really odd as well.
0
Ground texture comes up blurry using the UV Rect Tool Im trying to recreate the ground as this sample sprite sheet https opengameart.org content post apocalyptic expansion I downloaded the sprite sheet and extracted the top left block and saved it separately and added it as a default object not Sprite UI. I then added a UI Raw Image to my scene, added the imported texture. But as I expand it, it becomes blurry, even the UV rect does not seem to help. I though the UV rect was supposed to repeat the texture. Am I doing this wrong?
0
How do I hide the camera object in Unity Editor I have 2019 Unity Editor I have a huge camera object that is blocking all the other objects that I need to move in the scene, I want to hide this object, but I cannot find a hide show menu item anywhere or when I right click on the hierarchy
0
Clamping always returns 0 I have a class with three fields StartingAngleOnRotationPlane is 180 MinimumRotatedAngleX is 0 MaximumRotatedAngleX is 140 Here is the offending code public virtual float ClampRotatedDegreesWithinAllowedRange() float rotatedAngle this.transform.GetRotatedAngleOnXPlane() Debug.Log("Rotated " rotatedAngle) float clampedRotatedAngle Mathf.Clamp( AngleNormaliser.BetweenNegativeAndPositive180(this.StartingAngleOnRotationPlane rotatedAngle), this.MinimumRotatedAngleX, this.MaximumRotatedAngleX) return clampedRotatedAngle Here is the debug window As you can see, when the breakpoint was hit, rotatedAngle was 178.9446. To calculate clampedRotatedAngle, rotatedAngle is added to StartingAngleOnRotationPlane, supplied to a method called AngleNormaliser.BetweenNegativeAndPositive180(float input), and then clamped between MinimumRotatedAngleX (0) and MaximumRotatedAngleX (140). Here is the code for AngleNormaliser.BetweenNegativeAndPositive180(float input) public static float BetweenNegativeAndPositive180(float angleBetween0And360) while (angleBetween0And360 gt 180) angleBetween0And360 360 while (angleBetween0And360 lt 180) angleBetween0And360 360 return angleBetween0And360 Here is the debug window when AngleNormaliser.BetweenNegativeAndPositive180(float input) was invoked By the time the return statement was hit, the result 1.055389 should be returned and assigned to the variable clampedRotatedAngle, since 1.055389 is within the clamping range (0 140). However, that was not the case As you can see, clampedRotatedAngle was still zero. In fact, clampedRotatedAngle is always zero, regardless of what I feed into the Mathf.Clamp function How can I fix this?
0
How do I reduce the size of my symbols.zip? I am making an Android app in Unity. Google recommends using a symbols.zip, which Unity auto generates. However, the symbols.zip that Unity is generating for my app is over 1 GB, and the max size that Google will accept is 300 MB. How can I reduce the size of my symbols.zip?
0
How do I make an object's y axis align with a Vector3? I have a golf ball on the ground, and from a raycast, I have the normal which gives me the slope of the ground by the ball. I have an object which is rendered on the HUD to show that slope to the player. I have a parent object rotated 90 degrees around X, so that the indicator's Z axis points up. This way I can do this Quaternion yRot Quaternion.Euler(0, CameraController.Instance.CachedTransform.eulerAngles.y, 0) Vector3 displayGroundNormal yRot groundNormal lieIndicator3DParentCachedTransform.rotation Quaternion.LookRotation(displayGroundNormal) This, as far as I can tell, takes the ground normal, rotates it around the y axis so that it shows the proper perspective given the camera's facing. Then it tells that parent object to look in that direction, which aligns its z axis with the rotated ground normal. This works, except the object I have also rotates around the y axis depending on the orientation of the camera. I thought that I was throwing that information away in the second step by keeping only a Vector3 aligned with the ground normal rotated for the camera position. So I want this Not this
0
Rect transform stretch of a child object is set to 0 after instantiation I have the following hierarchy of my prefab PopupParent Popup ScreenDim They all have Rect Transform set to Stretch. Anchor mins are set to 0 and Anchor maxes to 1. Left, top, right and bottom are set to 0. When I pull this prefab to a Canvas manually, all works as expected. When I instantiate the prefab the problem I am encountering is, that the PopupParent is stretched as expected, to the full screen, but all its children are not. PopupParent looks like this Children Popup and ScreenDim look like this The instantiation I am doing using the Spawn Prefab Node in the Event editor provided by the ORK Framework. I am Mounting the PopupParent to my UICanvas. It could be, that the issue is caused by some Framework settings, but it might very well be related to how Unity works in general. I am not sure and can't find a way to figure it out. SOLUTION I got ORK support to reply and solve the issue for me http forum.orkframework.com discussion 6465 spawning a prefab with a stretch property latest TL DR Regular mounting and UI mounting works slightly different.
0
Unity add InputTracking to my script I'm new to unity and 3D world developement so I'm following Unity's tutorial for beginners right here. And I'm in the section with title "Camera Nodes" where they gave me a c script to attach it to the camera object. I did attach it to the camera but the problem with the script when I debug it I get an error of undefined class The name 'InputTracking' does not exist in this context And this is the script using System.Collections using System.Collections.Generic using UnityEngine public class UpdateEyeAnchors MonoBehaviour GameObject eyes new GameObject 2 string eyeAnchorNames "LeftEyeAnchor", "RightEyeAnchor" Use this for initialization void Start () Update is called once per frame void Update () for (int i 0 i lt 2 i) If the eye anchor is no longer a child of us, don't use it if (eyes i ! null amp amp eyes i .transform.parent ! transform) eyes i null If we don't have an eye anchor, try to find one or create one if (eyes i null) Transform t transform.Find(eyeAnchorNames i ) if (t) eyes i t.gameObject if (eyes i null) eyes i new GameObject(eyeAnchorNames i ) eyes i .transform.parent gameObject.transform Update the eye transform eyes i .transform.localPosition InputTracking.GetLocalPosition((VRNode)i) the error is this line eyes i .transform.localRotation InputTracking.GetLocalRotation((VRNode)i) and this one This is the link of the class InputTracking in Unity's API, but I don't know how to add it to my script ) Thanks in advance.
0
How to import .obj file from server without using asset bundle in unity3d I want to import .obj file from a server on run time in unity3D, read lot of questions answers but not able to find a suitable solution. Using WWW in unity I am able to get .png file and store it in local repository but this thing not works for .obj file. Following is the code I used to get image from server public string url "http images.earthcam.com ec metros ourcams fridays.jpg" IEnumerator Start() WWW www new WWW(url) while (!www.isDone) yield return www if (www.isDone) Debug.LogError ("Done") File.WriteAllBytes("C Users Admin Downloads conan test1.jpg", www.bytes) ans similarly I tried to get .obj file but it not works test .obj file created but without any data public string url "https drive.google.com open?id 0B5 UUyYa 2XdZUpuNlE4Z3pqWUk" IEnumerator Start() WWW www new WWW(url) while (!www.isDone) yield return www if (www.isDone) Debug.LogError ("Done") File.WriteAllBytes("C Users Admin Downloads conan test.obj", www.bytes) Kindly give me help in this regard.
0
Load scene without being in build settings and without using AssetBundle This is the closest I've gotten EditorSceneManager.OpenScene( AssetDatabase.GUIDToAssetPath( AssetDatabase.FindAssets( "t SceneAsset " MenuSceneName, new string "Assets" ) 0 ) ) However this generates an error at runtime InvalidOperationException This cannot be used during play mode, please use SceneManager.LoadScene() SceneManager.LoadSceneAsync() instead. I can't follow its suggestion because those functions require the scene to be in build settings or an asset bundle. So, is there any other option? I wonder how (and if) Addressables achieve this? Note I'm not willing to switch to Addressables I'm quite enjoying working with AssetBundles. Why? My game uses AssetBundles for general loading of EVERYTHING, so there's only one blank scene in build settings. However, during development I'd rather not have to continuously build and load from AssetBundles, so I'm trying to dynamically load scenes WITHOUT having to add them to build settings.
0
LineRenderer not working using Vuforia in Unity So I'm trying to render a line that shows up when camera sees an image target and moves around with it. Very typical AR application. But my line renderer doesn't seem to show at all. Here's the code using UnityEngine using System.Collections public class myLine MonoBehaviour Creates a line renderer that follows a Sin() function and animates it. public Color c1 Color.yellow public Color c2 Color.red public int lengthOfLineRenderer 20 void Start() LineRenderer lineRenderer gameObject.AddComponent lt LineRenderer gt () lineRenderer.material new Material(Shader.Find("Particles Additive")) lineRenderer.widthMultiplier 0.2f lineRenderer.positionCount lengthOfLineRenderer A simple 2 color gradient with a fixed alpha of 1.0f. float alpha 1.0f Gradient gradient new Gradient() gradient.SetKeys( new GradientColorKey new GradientColorKey(c1, 0.0f), new GradientColorKey(c2, 1.0f) , new GradientAlphaKey new GradientAlphaKey(alpha, 0.0f), new GradientAlphaKey(alpha, 1.0f) ) lineRenderer.colorGradient gradient void Update() LineRenderer lineRenderer GetComponent lt LineRenderer gt () var t Time.time for (int i 0 i lt lengthOfLineRenderer i ) lineRenderer.SetPosition(i, new Vector3(i 0.5f, Mathf.Sin(i t), 0.0f)) and here's my set up I also tried attaching the script directly to the ImageTarget and nothing happened.
0
Texture not appears? I make fat cube "fbx" with blender and export it to unity. this fat cube not allowed texture to appears ! i make a small cube by unity and texture pop up ! What is wrong ?
0
Unity Pixel Perfect Camera Adjusting the Viewport Rect? I am trying to make a pixel perfect Tetris style game. I have the pixel perfect component attached and have tried playing with settings such as Crop Frame and Stretch Fill. It seems to override any setting made to the 'Viewport Rect'. The problem here is I want to control where the play area is shown on the screen. For example I want the single player game to be somewhere near centre (although preferrably slightly off to the left). But when they play 2 Player mode I want the P1 playarea to be near left, and P2 area at the right. The screens below shows some of the settings I tried. The 3rd screen shot shows the play area approaching what I want, but I am unable to move it left to right for example (Im unable to move it at all). (Also note, if I try leaving CropFrame and StretchFill unchecked my Camera Size value is also overridden). I even tried to 'extend' the Pixel Perfect Camera class but haven't been able to do that, I'm starting to wonder if this is just a limitation of using this component and perhaps I would need to write my own implementation of the pixel perfect camera to achieve the full control I need. UPDATE Actually I am able to extend the Pixel Perfect Camera class by 'using UnityEngine.U2D'. So far this is what I am trying whilst I wait in hope of further help (It seems like a lost cause extending the class, because I am not sure I can override much from it and cannot see the code. I can't find a way to set the Viewport X or similar). All the best everyone! Thanks for any help.
0
How to create JSON file in notepad that will hold my positional vector3 data for one type of object I'm trying to get my head around using JSON files to store level data . Specifically in this example is to make my walls. (its a top down game like pacman). Each wall prefab is a 1x1x1 cube. I just want the JSON to hold the x,y,z. I have seen tutorials about how best to deserialise the data into Unity and I think im fine doing that, but I am unsure of how exactly to word the JSON file. I see the example on Unity docs says the format is like this "level" 1,"timeElapsed" 47.5,"playerName" "Dr Charles Francis" so, I could just do something like "index" 0,"x" 5,"y" 1,"z" 0 but I know that there needs to be a bit above, similar to XML and of this im clueless of what it needs to contain. I looked on Json.org but i didnt really understand it still. This is one example "glossary" "title" "example glossary", "GlossDiv" "title" "S", "GlossList" "GlossEntry" "ID" "SGML", "SortAs" "SGML", "GlossTerm" "Standard Generalized Markup Language", "Acronym" "SGML", "Abbrev" "ISO 8879 1986", "GlossDef" "para" "A meta markup language, used to create markup languages such as DocBook.", "GlossSeeAlso" "GML", "XML" , "GlossSee" "markup" But what is 'Glossary' and 'title' in the context of my game? All I currently have is a cube called Wall, with a script attached called Wall.cs that currently does nothing, but I will be making an array of Wall and plan on using the deserialised data from the json file to lay the Walls out using my GameController.cs Once I know what to put above and below to open and close the JSON file off, im pretty sure I can get it working how I need it to. I hope that made some sense.
0
Handwriting or handwritten text recognition in augmented reality Is there any way available to detect handwriting of a user using augmented reality within Unity. Or convert user hand written text into characters?
0
Player Flying after colliding Unity I have a Player with a capsule collider on him and i have various objects in the scene. Most of the objects have either mesh collider or box collider enabled. When i move my player and the player collides with any object, my player just starts flying into space, literally. Any way to fix this? Thanks in Advance. The code i have on my player is this using UnityEngine using System.Collections public class Controller MonoBehaviour Animator anim Rigidbody rbody float inputH float inputV int Life 20 bool Dead false public float sensitivity 10f void Start () anim GetComponent lt Animator gt () rbody GetComponent lt Rigidbody gt () void Update () if (Dead false) inputH Input.GetAxis ("Horizontal") 50f inputV Input.GetAxis ("Vertical") 20f anim.SetFloat ("inputH", inputH) anim.SetFloat ("inputV", inputV) float moveX inputV Time.deltaTime float moveZ inputH 0.5f Time.deltaTime this.transform.position this.transform.forward moveX this.transform.position this.transform.right moveZ transform.Rotate(0, Input.GetAxis("Mouse X") sensitivity, 0) if (Input.GetKey (KeyCode.Z)) Life if (Life 0) Dead true anim.SetBool("Dead",Dead)
0
Custom Inspector for textures? I am working with an open source project called Project Porcupine. The project is a game engine for a base building game that allows for one to extend the game. We have a system to read texture files, and use a .XML configuration file to parse the details of that file. This to me seems like a good use case for a custom inspector. Unfortunately, I can't figure out how to even configure the script to read in images as such, and google is letting me down. How can I write a custom editor for an image, even better if limited to a folder? Thanks! EDIT To clear things up a bit, I'm trying to make a custom inspector for images in the StreamingAssets folder. These assets are included with the build, and thus editable in Unity, but I would like to make a tool to make editing these a bit easier. Right now the inspector looks like this, the problem I'm having is getting anything to appear on the inspector at all. I've tried two things, first a Custom Inspector on TextureImporter, and using the following code, neither of which seemed to do anything. I would be happy to get anything printed in the Inspector, from that point I can figure out the rest, I hope. Thanks! using UnityEditor using UnityEngine public class SpriteXmlViewer AssetPostprocessor void OnPreprocessTexture() GUILayout.Label("Hello OnInspectorGUI!") Debug.Log("Test") Lastly, I'm clicking on the following image for the display above
0
How to know the size of object in Unity in world units? Suppose I have some external package with objects. Suppose I place some of these object to the scene. Now how to know actual size of object in world units? I found no any rulers or something in Unity. The I thought I can place primitive cube and compare it, but then I realized that I don't know the size of cube too. Is is possible to "measure" arbitrary object in Unity somehow?
0
How to tween to move an object in arc? Okay, so I think I need to use a tween in order to move an object in my game. I have some little green dudes that need to move in an arc (bezier) to a location that is clicked by the user. My game functions by having the mouse point raycast to the screen giving my character a position to move to. They don't just run though, they fire off their jetpacks and should travel in an arc to the target position. I'm pretty new to Unity but all I can come up with is using a tween to do this. Am I missing something? That being said, I'm totally confused on what a tween actually is. I can't wrap my head around how the object can be moved outside of an update function. I'm using the "free from the asset store" LeanTween package. I feel like there should be some sort of easier way to achieve the desired behavior. How can I have my character move from Vector3 A to Vector3 B in an arc?
0
Adding some recoil to the Camera so that the crosshair is pushing to the sky (FPS game) I just want to add some recoil to the camera, but I can't find a working script. It's an fps, so I take my mouse axis to rotate the camera. And now I want a pushback to the top, so that the camera looks into the sky after shooting a whole clip. It should be pretty easy, just add some amount to the axis, but it isn't working for me. I've got something like this from another post, but it just does nothing for me... I got a feeling that my axis is locked in some way, I'm using the "MouseLook" from the standart assets. transform.Rotate( recoil Time.deltaTime, 0, 0 ) Update This Script is working partially, but I think I reactivate the MouseLook too fast after the Rotate, so that the Mouse just jumps back to the starting position. mouseLook.enabled false transform.Rotate ( 5, 0, 0) mouseLook.enabled true
0
Unity web player API? Just curious about it. I only want to know that what graphics API does the Unity web player uses. Is that WEBGL? Or simply OPENGL? Or A custom one? Then how do the games get gpu acceleration?
0
Unity 2D Cinemachine weird behavior for non rectangular confiner I have been trying to emulate a sort of Megaman X4 way of following the player around platforming levels, where the camera is confined to certain boundaries of such levels. However, all the tutorials and guides out there only show rectangular or square shaped confiners for the virtual cameras, and not odd shapes like an L shaped confiner, when using a weirdly shaped confiner the camera just tends to snap from one position to another and the game ends up feeling bad when that happens. I have tried solving this problem by using dolly tracks, which work nicely... But I end up having tons of virtual cameras to change to on sections that are weirdly shaped since the camera ends up also suddenly snapping on to weird positions on sharp turns and it also tends to get way off track, even when the settings of the virtual camera are configured to have very little damping and if there's no damping the camera just stutters all the time. Is there a way to have this kind of behavior to confine a virtual camera to oddly shaped level boundaries?
0
Run playing game in full screen on one display, Unity IDE in another I have multiple monitors ( ). If the Unity (2018.1) IDE is open and maximized in one of them, is there an easy way to have it use one of the OTHER displays to run the game full screen whenever I launch 'play' mode? Or alternatively, to undock the "Game" tab from the IDE amp turn it into a normal window that can be moved to an adjacent display amp maximized? ( ) If it matters, I'm running Windows 10, with the desktop extended across all three. The left and middle (main) displays are connected via DVI, the right display is my laptop (Dell Precision m4800 with Quadro K2100M). All three are 1920x1080.
0
VBO interleaving dillema I'm trying to write a map editor for a unity game using openGL. In order to do that, I need to unpack it's resource files to get meshes, textures and other good stuff. In doing so, I've discovered that unity mesh asset stores vertices, normals, texture data, and any other per vertex type data in one interleaved array. I have two choices here. First is to leave the data as is and push it into a single VBO and then use attrib pointer to adjust strides and whatnots to make it work. When I read data from file into memory, I can just read whole array with a single ifstream read method call. Second choice is to unravel all data into it's separate channels and have a separate VBO for each data type. I personally prefer it this way, but this means that I need to deinterleave that array. I'm unsure how to do this efficiently. The most obvious way (and very inefficient) is to read it char by char and store each char in appropriate array, depending on channel structure. I could maybe mess with it a bit and set it up to read it channel per channel (meaning 2 4 chars at once) instead of char by char. This still seems very slow to me. Maybe I could load the whole array into memory and then deinterleave it there, but I'm still unsure of method that would be fast. The priority is for the program to be fast while drawing, and deinterleaved multiple VBO setup is said to be faster due to lesser amount of cache misses. To give you a sense of numbers, the game I'm looking at contains about 2630 different mesh assets, with each containing an estimated average of 500 vertices. How do I deal with this? I will be loading all this data just once on program startup anyway, so it doesn't have to be super fast, but I don't want to force the user to wait for too long even then. Maybe number of vertices altogether is small enough for it to be very fast regardless, but I don't want to commit to either way before I have some idea of what I'm doing. Bottom line is, should I just leave it interleaved, or is there some efficient way to deinterleave it? Am I jumping the train here, being scared of leaving it interlaved? I know I should probably benchmark both cases, but both cases are drastically different in my case and would require huge code changes, not to mention I'm nowhere close to actually drawing the scene I need to.
0
Some autocompletion doesn't work in Visual Studio Code with Unity I am using Unity 2018 with Visual Studio Code version 1.43.2 on a Mac. Things seemed to work fine between Unity and Visual Studio Code, but now I realize that something is wrong with Code. I have been following along with a tutorial and the autocompletion functionality of Code seemed fine until the function OnTriggerEnter, which was shown as autocompleting for the guy in the video (who was using the other Visual Studio), didn't fill in. However, many other Unity things do automatically show up as options. I looked at this Microsoft help page about VS Code and Unity, and I have everything it I seems I would possibly need to combine the two I have .NET, Mono, Debugger for Unity, the C extension, and got Unity Tools for good measure. Generic C things like return, void, int, etc. autocomplete, so the C extension seems fine. Many Unity things, like Vector3, GameObject, Destroy, transform, etc. also autocomplete like they should. What is wrong here? How can I fix this and get full autocomplete?
0
Trying to create a '2D 8 Ball Pool' game Trajectory Prediction I am trying to create a game similar to (Pocket Run Pool) https www.youtube.com watch?v ewlAE6NQnsI amp t 215s a 2D pool game that is much simpler than a 3D one I need help with creating code for trajectory prediction something similar to this https docs.unity3d.com Manual physics multi scene.html How do I go about doing this?
0
2D 3D Soft body physics in Unity I want to implement soft bodies in my game similar to this link. I tried using this Soft body simulation plugin but it has the following problems Only works with box colliders. Doesn t work with Unity s physics engine i.e. the bodies don t react to the forces applied. For my game, The soft bodies should be able to collide and interact with any types of colliders (including mesh collider). The bodies should work with Unity s physics engine i.e. the bodies should react to the forces and gravity applied. I am flexible in implementing soft bodies in 2D or 3D. I would appreciate any suggestions and thoughts on this topic.
0
How to add a volume bar like YouTube for iOS? I am almost done with my game in Unity 5. However when the player presses Volume Up Down, the iOS (version) shows the standard UI to show volume. Android has it's own (looks better on Stock). I want to make my game consistent on either platform and different variations of Android. So I want to recreate how YouTube (for iOS) handles the change in volume. I can't figure this out. Any help would be awesome!!!
0
How do I create indoor scene lighting? I'm building the inside of a space ship in Unity as POC. I need info on scene lighting. Rooms, corridors or just in general how to make an enclosed scene look great with lights. Keep in mind this is indoors and I can't really use the Directional Light and have to rely on realistic light sources. Thanks!
0
Unity run time creating material has performance impact? Just found creating a material in a script for the first time would have performance impact. (Using Unity 5.6.5f) A very simple script for testing is to create a game object with MeshRenderer in Start(), assign a new material each time in Update(), gameObj.GetComponent lt MeshRenderer gt ().material new Material(Shader.Find("Standard")) From Unity Profiler the first function call took much longer than following calls, the first one took 100ms and others less then 1ms. Can someone give it an explanation? Thanks.
0
Player disappears when it collides with a tagged object I am working on a simple game where the goal is to help a Player catch specific objects with a tag "Present". After taking care of the models, animations I am now working on the collisions and counting UI. For the collisions, on my Player Controller (I am using the ThridPersonUserController from the player Unity Standard Assets which simplified the whole animation process), I added the following functions void OnCollisionEnter(Collision other) if (other.gameObject.tag "Present") Destroy(gameObject) count count 1 SetCountText() void SetCountText() countText.text "Count " count.ToString() if (count 0) winText.text "Thanks to you the Christmas will be memorable!" However, like this, when the Player hits an object with the tag "Present", even though the counting is working properly, the player disappears. I have tried to change the OnCollisionEnter to an OnTriggerEnter, like this void OnTriggerEnter(Collider other) if (other.gameObject.CompareTag("Present")) Destroy(gameObject) count count 1 SetCountText() However when the Player hits the objects with the tag "Present", they don't disappear. My Player has a Capsule Collider and a Rigidbody. The objects with the tag "Present" have a Box Collider and a Rigidbody. Any guidance on how to make my Player stay in scene while removing the other objetcs and reducing the count is appreciated.
0
Unity How to make script work with duplicated objects? I have an object in my game that, when clicked, causes the player to move toward it. It does this by sending its position to the player's SetTarget function. The player's Move function then heads toward the position. This is working, but when I duplicate the object and click on it, the player still moves toward the original object's position. When I print debugging statements to the console, it appears that both positions are being calculated, but the original position is the last one and wins out. (I'm using the object's this.transform.position to send the position to the player's SetTarget function.) Can I not duplicate objects like this and expect the script to work? Do I need to use a prefab? If so, how? I know how to create prefabs but am not sure what I would need to change with the script or other settings when they are created. Thanks. Here's the code public class PotController MonoBehaviour private GameObject chefObject void Start () chefObject GameObject.Find ("Chef") void Update() if(Input.GetMouseButtonDown(0)) print ("pot clicked!") ChefController chefScript chefObject.GetComponent lt ChefController gt () print (this.gameObject.transform.position) chefScript.SetTheTarget (this.gameObject.transform.position) public class ChefController MonoBehaviour private Vector3 target public float speed 2 Use this for initialization void Start () target this.transform.position private void MoveTowardsTarget() Vector3 targetPosition new Vector3(0,0,0) targetPosition target Vector3 currentPosition this.transform.position check distance to target if(Vector3.Distance(currentPosition, targetPosition) gt 0.4f) Vector3 directionOfTravel targetPosition currentPosition directionOfTravel.Normalize() this.transform.Translate( (directionOfTravel.x speed Time.deltaTime), (directionOfTravel.y speed Time.deltaTime), (directionOfTravel.z speed Time.deltaTime), Space.World) void Update () MoveTowardsTarget () public void SetTheTarget (Vector3 position) target position
0
Unity Lighting Problems I've got a problem with the settings of lighting in my unity scene. The objects have got "dark sides" and it doesn't look natural. You can see the screenshots and my light settings here The screenshot that shows the problem
0
Unity sprites rendering problems on Android I'm creating a simple 2d game for android, with normal sprites and animations. The problem is that when I open the game on my smartphone (Samsung galaxy trend plus), The sprites are rendered this way Of course, this is not what should happen. Moreover, within the Unity editor everything works flawlessly. My settings for the export are Texture compressions ETC2 (GLES 3.0) Tested also with "Don't override" Player settings Default orientation landscape Use 32 bit display buffer unchecked tried also with this option checked Rendering path forward tried also with Legacy Deferred Static batching Dynamic batching both checked Camera settings Clear flags Solid color tried also skybox I don't have any other scene, and this one has only one camera (I saw some topics where people were having problems because they had two or more cameras). The sprites are all .png images with transparence, except for the background, that has no transparence, but is lagging. There are three sprites which are animated using the spritesheet, but they're terribly lagging, and almost can't be seen in this screenshot. I really can't understand why, I'll continue to try, waiting for your answers. Thank you in advance! EDIT If in the player settings the orientation is set to auto rotate and the device is in portrait, all the sprites works perfectly!!! The problem is that my game is meant for landscape...
0
How to play and pause animation I want to make play and pause buttons to play and pause sound and also I want it to play and pause animation ,how should I do that? function public void TogglePlay() if (audio.isPlaying) audio.Pause() else audio.Play()
0
Unity3D Raycasting in Start behaves uncorrectly, but works correctly in Update? I have this method, which just raycasts at a position downwards, and checks what tile is there, if there is one public static Tile RaycastTile(Vector3 position) Debug.Log("raycastTile at pos " position) var layerMask 1 lt lt LayerMask.NameToLayer("Floor") RaycastHit hit Debug.DrawRay(position, new Vector3(0, 10, 0), Color.red, 50) if (Physics.Raycast(position, new Vector3(0, 1, 0), out hit, 10, layerMask)) var tile hit.collider.gameObject.transform Debug.LogWarning(tile.name " " tile.parent.name " at pos " tile.position) var coordinates new Vector2Int(Mathf.RoundToInt(tile.position.x) 2, Mathf.RoundToInt(tile.position.z) 2) return map.GetTile(coordinates) else Debug.LogError("Tile not found under position " position) Debug.Break() return null Currently it is called for the player at Start() ("starting at lt player's absolute position ") and at Update() ("update at pos lt player's absolute position ") And the map is being generated (tiles created, destroyed, etc) in Awake(). and for some reason this is the output And the map generation works like this Creates a room at (0, 0) with tiles and all, then it searches for a connection point on the existing map, whom the new room could be connected to. (with some rotation, if it's needed) (Every tile is 2x2 meters, and they are on a strict grid) So for some reason calling this method at Start() (with the same position) hits a totally different tile. While in Update() it works correctly. At first I thought that it's because of Destroy(), because the objects are only destroyed at the end of the frame. But I tried DestroyImmediate() and it didn't help. (And after thinking, I realised that destroying objects at the end of the frame wouldn't cause issues. Or is it?) Then I had the idea, that maybe Start doesn't wait for Awake because it compute heavy. And the raycast in the Start hits a (yet) non translated newly generated room. So I edited the code so every room is initially created at very far away, which is relatively "infinite far away" from the player at (9999, 9999). But the issue remained. EDIT With (9999, 9999) Sometimes (maybe half of the time?) now it is correctly raycasted even at start, while before it was never correct in start. EDIT2 With (0, 0) it hits correctly at start as well, but very very rarely. Do you have any idea what could cause this issue? Sorry if there isn't enough info, feel free to ask. )
0
Unity3D WWW get HTML displayed in browser I currently have in a web page, on a localhost server, some information that I want to use in Unity. My problem is that this information are stored in some js variables. I tried to use the WWW class in a coroutine, but I only get the html source code. Is there a way to get the value of this variables inside Unity Editor ? Thanks !
0
Quaternion.Lerp does not actually rotate object when called inside an "if" clause Let's say I have a RotatableObject class, which inherits from MonoBehaviour. Here is its Start() method private void Start() this.startingLocalRotation this.transform.localRotation this.finalLocalRotation Quaternion.Euler(this.startingLocalRotation.eulerAngles.x, 150f, this.startingLocalRotation.eulerAngles.z) Initialize other private fields It has a method called Rotate(), defined as follows private void Rotate() this.transform.localRotation Quaternion.Lerp(this.startingLocalRotation, this.finalLocalRotation, 0.2f) Given the following Update() method, the object rotates as expected private void Update() this.Rotate() However, if I make the following changes to Update(), then the object does not actually rotate, even though the Rotate() method is hit private void Update() if (this.SomeCondition) this.Rotate() this.SomeCondition always has the value true over multiple frames. What is my mistake, and how can I fix it? EDIT In response to this comment When you say "the object rotates as expected" do you mean that the object rotates from starting angles until final angles and then stops rotating (without the if) ? Yes. could you provide some more details about what SomeCondition is? this.SomeCondition is determined by the state of another object, say, Puppy. E.g. if puppyInstance.Mood Mood.Happy, then this.SomeCondition is true. Did you try replacing the condition with the word true No, I have not tried that. However, when stepping through the call stack in debug mode, I can see that this.SomeCondition is true and Rotate() is called I managed to step into the Rotate() method itself. EDIT I tried the first approach described in this answer. However, it did not produce the effects that I was aiming for. I set a breakpoint here transform.localRotation Quaternion.Lerp( startingLocalRotation, finalLocalRotation, rotationProgress ) Every single time the breakpoint was hit in the Update() call, I could see that the value of rotationProgress was steadily increasing. However, the value of transform.localRotation never actually changed it was always ( 0.7, 0.7, 0.0, 0.0). If I updated transform.localRotation outside of an if clause, however, that game object rotates as expected transform.localRotation gets updated as rotationProgress gets updated. EDIT Never mind, I am an idiot. The problem lies elsewhere in the code. The suggested approach works and I have accepted it as the answer.
0
How to calculate score in my game based on playtime and coins picked? I've been trying to figure out a way to calculate the score in my game.... but nothing seems to work properly... The score is to be calculated according to playtime coins collected. The playtime should be as low as possible and number of coins should be as high as possible. For example Let's say an idle play for a level X has playtime 15 seconds coins 20. The score is 100. Then what will be the score when the playtime 20 seconds coins 14. P.S. Pardon me if the example is wrong but I can't figure out how to explain my problem... Thanks in advance.
0
Reasons to not use Root Motion Engine Unity 3D tool Blender Since the start of my game dev endeavour, I can't seem to decide on the type of animation system I want to use. Can someone please give me reasons why you would NOT use root motion and maybe a real world example, because currently I see no reason to not use root motion. I understand the loss of control when using root motion, but from my understanding, the amount of control is "enough". Treadmill motion(stationary animations) seems like it wont look good enough because you have to perfectly match your move speed to animations. I just need either a resource or proper answer on the specifics about why you would use one over the other or a blend(treadmill for walking, root for jumping etc). Appreciate any help provided.
0
How to add tiles randomly? I made a set of 10 different "ocean" tiles, all interchangeable with one another, and I'd like to randomly attach these 10 different tiles together in different combinations over a large rectangular area what would be the best way to do so? I've thought of just adding each sprite into a script and then calling a for foreach loop to add it into my world but that seems extremely expensive since I'd be adding over 1000 sprites. I don't want to reduce the number of sprites I have to add, I'm just seeing if there's a typical way people do this sort of thing.
0
Move object along world X Z axes taking account it's own rotation I have a camera 9 units up, tilted down at a 60 angle (rotated around it's X Axis), which means forward for the camera is pointed down at the floor as shown in the picture below Now when I press W, i want the camera to move horizontally forward without changing it's Y coordinate, but not along the world Z axis, as that breaks when the camera is rotated around it's Y axis. Here are a few images demonstrating what I want Side view Top view
0
In Unity, how to hide objects from specific cameras without using Layers The situation is that there are multiple players that can collect items. When a player collects an item, the item will disappear from that player's screen but still be visible to other players. I know I can use LayerMask to achieve this effect. However, what if there are more than 32 players? (Unity Layer has 32 bits). How can I still hold this effect? I tried using OnWillRender() to check which camera is rendering the object in order to disable its renderer. This does not work because once the renderer has been disabled, OnWillRender() will not be called again for other cameras.
0
gpu rotate a texture2d or rendertexture How does one gpu rotate a Texture2D or RenderTexture using Unity c ? Or, is that possible? I think it might be something like this... I'm also trying to understand how gpu scale seems to work here? Internal unility that renders the source texture into the RTT the scaling method itself. static void gpu scale(Texture2D src, int width, int height, FilterMode fmode FilterMode.Trilinear) We need the source texture in VRAM because we render with it src.filterMode fmode src.Apply(true) Using RTT for best quality and performance. Thanks, Unity 5 RenderTexture rtt new RenderTexture(width, height, 32) Set the RTT in order to render to it Graphics.SetRenderTarget(rtt) Setup 2D matrix in range 0..1, so nobody needs to care about sized GL.LoadPixelMatrix(0, 1, 1, 0) Then clear amp draw the texture to fill the entire RTT. GL.Clear(true, true, new Color(0, 0, 0, 0)) Graphics.DrawTexture(new Rect(0, 0, 1, 1), src) Edit The input image is rotated 90 degrees ccw to fit in the left part (replacing the beige with pink dots) of this texture (no alpha is needed). If you want some numbers, it's a rect from 0,0 to new Vector2(794, 1024)
0
How can I draw a linerenderer line between two vector3 positions using the mouse left button click? This code is drawing a line but it's not drawing it on the camera in front of the camera. using UnityEngine using System.Collections using System.Collections.Generic public class DemoScriptDraw MonoBehaviour private List lt Vector3 gt positions new List lt Vector3 gt () private LineRenderer lr private void Start() lr this.GetComponent lt LineRenderer gt () private void Update() if (Input.GetMouseButtonDown(0)) Vector3 pos Input.mousePosition pos Camera.main.ScreenToWorldPoint(new Vector3(pos.x, pos.y, lr.transform.position.z)) positions.Add(pos) if ( positions.Count 2) SpawnLineGenerator( positions 0 , positions 1 , Color.red) void SpawnLineGenerator(Vector3 start, Vector3 end, Color color) GameObject myLine new GameObject() myLine.AddComponent lt LineRenderer gt () myLine.AddComponent lt EndHolder gt () LineRenderer lr myLine.GetComponent lt LineRenderer gt () lr.material new Material(Shader.Find("Particles Alpha Blended Premultiply")) lr.startColor color lr.useWorldSpace true lr.endColor color lr.startWidth 0.1f 0.03f lr.endWidth 0.1f 0.03f lr.SetPosition(0, start) lr.SetPosition(1, end) The result is that the line is seen in the scene view window but not in the game view window
0
Compute shader Property at kernel index is not set I am trying to follow this excellent Coding Adventure https www.youtube.com watch?v lctXaT9pxA0 in order to get a very simple mesh deformation on a mesh using a compute shader. I'm getting an error that reads Compute shader (NewComputeShader) Property (vertices) at kernel index (0) is not set UnityEngine.ComputeShader Dispatch(Int32, Int32, Int32, Int32) MoonShader runShader() (at Assets MoonShader.cs 27) MoonShader Update() (at Assets MoonShader.cs 15) I'm calling runShader() in Update (maybe that's a terrible idea, but I don't think it's contributing to this specific problem yet). Do I need to somehow pass my mesh's vertices into StructuredBuffer lt float3 gt vertices ? If so, how am I supposed to do that? This is the call to the compute shader in my .cs file. void runShader() int kernelHandle computeShader.FindKernel( quot CSMain quot ) computeShader.Dispatch(kernelHandle, 512, 1, 1) this is the line it appears to be complaining about This is my .compute file. pragma kernel CSMain StructuredBuffer lt float3 gt vertices RWStructuredBuffer lt float gt heights uint numVertices float testValue 20 numthreads(512,1,1) void CSMain (uint id SV DispatchThreadID) if(id gt numVertices) else float3 vertexPosition vertices id heights id 1 sin(vertexPosition.y testValue) 0.05 Link to repo if it's helpful https github.com glenpierce proceduralPlanets
0
Unity Seamless Terrain I am programmatically generating terrain using unity's terrain object and assigning height maps to it via the terrainData, the problem is that there are seams even when using the GroupingId(which is used for auto connect). I even tried creating a terrain object in the editor with neighbours, and modified their terrain data via script, seams still there. I have also tried SetConnectivityDirty after applying terrainData. Most people who have reported this seemed(lol) to have issues with their normals at the edges, I cant see that being the issue here, but if it is, how do i approach solving it given I am using unity terrains. If there is no good answer I will have to resort to custom meshes and lose all the nice terrain tool functionality. Edit Here is how I'm setting heights. var terrain GameObject.Find("test").GetComponent lt Terrain gt () var terrainData terrain.terrainData var noiseMap Tool Generators.GenerateNoiseMap(chunkSize, seed, scale, octaves, persistance, lacunarity, 0f, 0f) terrainData.SetHeights(0, 0, noiseMap) Then the actual noise generation is just a 2D array of heights, i have been using a simplified version with only 1 pass for testing. public static float , GenerateNoiseMap(int chunkSize, int seed, float scale, int octaves, float persistance, float lacunarity, float offsetX, float offsetY) float , noiseMap new float chunkSize, chunkSize for (int y 0 y lt chunkSize y ) for (int x 0 x lt chunkSize x ) float noiseHeight 0 float sampleX (x offsetX) scale float sampleY (y offsetY) scale noiseHeight Mathf.PerlinNoise(sampleX, sampleY) noiseMap y, x noiseHeight return noiseMap
0
How to use HD and SD sprites in Unity addressables I am able to load sprites using Unity addressables. But how can I use SD or HD variants of a sprite based on my device resolution? Previously I was using LIBGDX, and it has ResolutionFileResolver to handle this scenario.
0
Add object to a Terrain? It's possible to add object made by blender to unity terrain ? this object will become a part of it. I can add grass and trees on it.
0
How do I set up a dedicated server for my multiplayer Unity game? I've made a multiplayer game with Unity and Mirror networking, and it all works perfectly when just running it on my own computer. However, I am trying to host on a dedicated server so that I can put the project on my portfolio and not have to worry about whether players can log in and test play the game or not. I tried a AWS Free server and I see that the Tanks example from Mirror is working just fine (although laggy), but my own project doesn't. I think this has something to do with the RAM limit of the free server but I'm not sure. I can see the task manager going up to 95 memory usage. When I remove some particle effects and geometry and enemies, it works. I'm not sure if this is my code that is so cloggy or the server or both. In any case I would need a solution for this but I don't know what my options are. Would be great if anyone can point me in the right direction. Thanks!
0
Huge 2d pixelized world I would like to make a game field in a indie strategic 2d game to be some a like this popular picture. So every "pixel"(blocks) changes it's color slowly, sometimes a bright color wave happens, etc, but the spaces beetwen this pixels should stay dark (not to count shades, lightning and other 3rd party stuff going on). Units are going to be same "pixelized" and should position them selfs according those blocks. I have some experience in game developing, but this task seems not trivial for me. What approaches (shader, tons of sprites or code render, i don't now) would you recommend me to follow? (I'm thinking of making this game using Unity Engine) Thanks everyone! )
0
How can I draw a linerenderer line between two vector3 positions using the mouse left button click? This code is drawing a line but it's not drawing it on the camera in front of the camera. using UnityEngine using System.Collections using System.Collections.Generic public class DemoScriptDraw MonoBehaviour private List lt Vector3 gt positions new List lt Vector3 gt () private LineRenderer lr private void Start() lr this.GetComponent lt LineRenderer gt () private void Update() if (Input.GetMouseButtonDown(0)) Vector3 pos Input.mousePosition pos Camera.main.ScreenToWorldPoint(new Vector3(pos.x, pos.y, lr.transform.position.z)) positions.Add(pos) if ( positions.Count 2) SpawnLineGenerator( positions 0 , positions 1 , Color.red) void SpawnLineGenerator(Vector3 start, Vector3 end, Color color) GameObject myLine new GameObject() myLine.AddComponent lt LineRenderer gt () myLine.AddComponent lt EndHolder gt () LineRenderer lr myLine.GetComponent lt LineRenderer gt () lr.material new Material(Shader.Find("Particles Alpha Blended Premultiply")) lr.startColor color lr.useWorldSpace true lr.endColor color lr.startWidth 0.1f 0.03f lr.endWidth 0.1f 0.03f lr.SetPosition(0, start) lr.SetPosition(1, end) The result is that the line is seen in the scene view window but not in the game view window
0
Did they remove Sprite sorting layers from Unity? I can't figure out how to set it. I thought it was a setting on the sprite renderer but it doesn't seem to be there? Google isn't turning up any results.
0
Bubble Text appears issue? I'm trying to make a dialogue between characters using bubbles witth text. But the text appears not clear to player. The Cam is far from the canvas 13.5f. What to do fix it ?
0
Unity 5 Manually zooming scaling in and out of an image with a text layer while still retaining text sharpness when zoomed? I have a section in my scene where I have an image on a layer, as a child of this layer I have a load of text objects. I need the ability to zoom in and out of the image (it's a technical drawing, so necessary to zoom in and out), so I have set up a simple Scale of the image itself (via Playmaker) and applied the zoom in to a button and the zoom out to another button. When zoomed out, the image Scale is set to the default 1 and when zoomed in it goes to Scale 3. It works perfectly. I have also added a 'Scroll Rect' to the parent canvas, this enables me to click and scroll around the image when it is zoomed in this also works perfectly. However the main problem I have is that while the image looks fine zoomed in (the original image is a large size, so looks fine even when scaled up to Scale 3) the text does not look good when scaled. It is essentially just 'zooming' in on the text and therefore the bigger it gets, the worse it looks. Text is set to 'Best Fit' it has to be this way due to the fact I have dynamic translations on the text, so the text needs to stay within its specified area and shrink if necessary. Ideally I would like the text size to scale in line with the image scale ie. if the text is size 10 when zoomed out, then it should be size 30 when zoomed x3 (as opposed to a scaled size 10) is this possible? The text must stay in the exact same position relative to the image, as text is placed at specific points on the drawing. The text also needs to be able to be scrolled in exact line with the image (hence why I have it as a child of it, so it follows nicely). Canvas is set to 'Screen Space Overlay' with 'Scale with Screen Size' and 'height' at 1 (works perfectly across the game like this). Screenshots attached... Canvas Text Any help would be appreciated. Thanks in advance Unity 5.3.5 PC Mac Standalone only
0
Authoritative Server for single player but with leaderboard I made a Fps single player, timed survival with a leaderboard ( a bit like devil daggers and others). I know would like to create a server that will prevent cheats such as avoiding collision or altering the timer. My issue is I don't know the theory on how should my server behave. Should it run an instance of the game per player which will handle the collision and other stuff for that player ? is this viable Any advice ?
0
Spawn prefabs from list one by one when trigger is touched I am trying to spawn one gameobject from a list of gameobjects each time I touch the trigger with the controller. But when I do this, all the game objects from the list spawn together at the same time. I couldn't figure out how to solve this problem and make them spawn one at a time instead, where the next touch spawns the next object in the list, and so on. using System.Collections using System.Collections.Generic using UnityEngine public class Trigger MonoBehaviour public Transform spawnPoint public GameObject Prefab public List lt GameObject gt items new List lt GameObject gt () void OnTriggerEnter(Collider other) GameObject Prefab new GameObject("prefab") for (int i 0 i lt items.Count i ) Instantiate(items i , spawnPoint.position, spawnPoint.rotation) Debug.Log("Hello World" i)
0
Change players state and controls in game I'm using Unity 3D Let's say the player is an ice cube. You control it like a normal player. On press of a button, ice transforms (with animation) into water. You control it completely different than the ice cube. Another great example would be Player is human being and has normal FPS controls. On press of a button human transforms into birds and now has completely different controls. Now, my question is, what would be easier and better make one object with animation transition and to stay in that state of anim. until button is pressed again make two object ice and water. Ice has an animation of turning into water. So replace ice (with animation) with water object And if anyone knows this one too how to switch between 2 different types of player controls.
0
GraphView Dragging a Blackboard causes it to get stuck offscreen I'm playing around with learning GraphView, and running into some strange problems with the Blackboard component. Here's a very simple repro using UnityEditor.Experimental.GraphView using UnityEngine.UIElements public class MyGraphView GraphView public override Blackboard GetBlackboard() var result new Blackboard(this) COMMENTED OUT BLOCK 1 var c result.capabilities result.capabilities c amp Capabilities.Movable COMMENTED OUT BLOCK 2 result.RegisterCallback lt MouseDownEvent gt (OnMouseDown) result.RegisterCallback lt MouseUpEvent gt (OnMouseUp) result.RegisterCallback lt MouseMoveEvent gt (OnMouseMove) return result public override void ReleaseBlackboard(Blackboard toRelease) toRelease.RemoveFromHierarchy() COMMENTED OUT BLOCK 3 toRelease.UnregisterCallback lt MouseDownEvent gt (OnMouseDown) toRelease.UnregisterCallback lt MouseUpEvent gt (OnMouseUp) toRelease.UnregisterCallback lt MouseMoveEvent gt (OnMouseMove) private static void OnMouseDown(MouseDownEvent e) e.StopImmediatePropagation() private static void OnMouseUp(MouseUpEvent e) e.StopImmediatePropagation() private static void OnMouseMove(MouseMoveEvent e) e.StopImmediatePropagation() using System.Collections.Generic using System.Linq using UnityEditor public class MyGraphEditor GraphViewEditorWindow protected MyGraphView view public override IEnumerable lt GraphView gt graphViews get yield return view private void OnEnable() view new MyGraphView() this.rootVisualElement.Add( view) view.style.height new StyleLength(new Length(100, LengthUnit.Percent)) MenuItem( quot Tools Graph Editor Test quot ) public static void ShowWindow() var graphViewWindow CreateInstance lt MyGraphEditor gt () var graphView graphViewWindow.graphViews.FirstOrDefault() if (graphView ! null) var blackboard graphView.GetBlackboard() graphView.AddElement(blackboard) graphViewWindow.Show() Clicking the new menu item causes the window to open, just a blank editor window with a blank Blackboard. Clicking on the title bar of the Blackboard and attempting to drag it, though, causes it to immediately disappear. Checking in the UIElements Debugger shows that this is because it's somehow gotten its World Bound Y set to 79, so it's disappeared off the top of the window. A bit of checking in the reference source suggests that if the Blackboard was not Movable, it couldn't be dragged around. Not ideal, but a temporary workaround at least. But if you uncomment the code that sets this up, (commented out block 1,) it breaks the editor entirely clicking on the Blackboard causes Unity to stop responding to mouse clicks. Attempting to minimize the damage with the other two commented out blocks has no effect. Anyone have any idea what's going wrong here and how to fix it? What do I need to do to have a Blackboard that can be dragged around properly?
0
Why is the ownership fixed when synching objects? I'm creating a billiard game where one white ball will be controlled by two online players. I have set my object photonview to ownership takeover. When a player shoots the ball in one client, it is synced on other client. Now when I update the ball on the other client, the other client is not updated. Why is the ownership fixed? Only one client is sending the updates to the other client, and not vice versa. What should I do here?
0
Unexpected results during collisions in Unity I've got a basic car based game I'm starting in Unity. Currently the scene has only a floor, a car (player controlled), and one building. Bumping into the building at low to medium speeds works as expected. When getting the car up to max speed and smashing into the building, though, weird results happen. Originally, the car was being pushed through the floor and falling off the map. I changed the floor from a plane to a cube that was stretched to be broad and flat (scale 2 height), and that helped. Now the car seems to clip right through the building at top speed, sometimes flipping itself into the air when it emerges. So what gives? The car and building are both imported .fbx models and both have box colliders stretched to the outer bounds of the models. The car has a rigid body with gravity. The building used to have a rigid body, but I removed it once I realized it was making the building fly into the air on impact (which was definitely not what I wanted). Here are the relevant parts of the movement code bool key up false float top speed 1f float current speed 0f float acceleration .01f void Update () if (Input.GetKeyDown (KeyCode.UpArrow) amp amp !key up) key up true if (Input.GetKeyUp (KeyCode.UpArrow) amp amp key up) key up false if (key up) if (current speed lt top speed) current speed acceleration else if (current speed gt .1f amp amp current speed lt .1f) current speed 0f if (current speed ! 0f) current speed current speed 0.9f transform.Translate (0f, 0f, current speed) Update After switching the camera to a fixed position (rather than following the car), I've gotten better observations. The car will clip right through at any speed if I keep pushing forward. There's initial resistance from the collision detection and some stuttering from the car, but it always breaks through and then flips into the air on its way out. I've added the following function to the car code void OnCollisionEnter (Collision collision info) current speed 0f current speed is what's being used to translate the car forward each frame. This has slowed the bug down, but the car always eventually pushes through if I hold down the gas long enough. It looks as if Unity's collision detection isn't moving the car back far enough on each frame that the car is colliding. Must I handle that portion on my own?
0
How do I move a Unity object with velocity instead of force? I have a 2d car in Unity that I want to move, but Unity does this using relative force amp I want to use velocity. As we know if we add force, an object will move and never stop. I want to use velocity to control movement, because then the car will stop when its velocity is zero. using System.Collections using System.Collections.Generic using UnityEngine public class GamePlay MonoBehaviour public GameObject player public Rigidbody2D rb public float speed, steering void Start() void FixedUpdate() rb.AddRelativeForce(Vector2.up speed) rb.velocity Vector2.up Touch touch Input.GetTouch(0) if (Input.touchCount gt 0) if (touch.phase TouchPhase.Moved) Vector2 v Camera.main.ScreenToWorldPoint(touch.position) float pos touch.position.y player.transform.Rotate(0, 0, pos steering)
0
Unity Visual Effect Play() has no effect I am making my first visual effects, and I make effect, when my ship is flying. So I am want to play it only when the ship is actually moving. I would suppose it's easy, you call Play(), it will play. You play Stop() it will stop. But when I call play, nothing happens. public void Update() ship.Rotate(Input.GetAxis( quot Horizontal quot )) var move Input.GetAxis( quot Vertical quot ) ship.Move(move) if (move gt 0) FlyEffect.Play() FlyEffect.SetVector3( quot Velocity quot , new Vector3(0, ship.Speed move, 0)) else FlyEffect.Stop() When I let in Initial Event Name OnPlay, it is playing as it should be. But nothing from the script... What I am missing here?
0
How do I create a Button when I click another Button? I need help. When I click a Button, I want to create a new Button. My code, however, creates four Buttons. What should I do? using UnityEngine using System.Collections using UnityEngine.UI using System.Collections.Generic public class AddButton MonoBehaviour public GameObject prefabButton public RectTransform ParentPanel public Button saveButton void Update() if (Input.GetMouseButton(0)) for (int i 0 i lt 2 i ) GameObject button (GameObject)Instantiate(prefabButton) as GameObject button.transform.SetParent(ParentPanel, false) button.transform.localScale new Vector3(1, 1, 1)
0
Random Sobol 3D Cell in Unity There is a blueprint in UE4 for making Sobol random 3D cell. It places random objects inside cell structure. How to make this in Unity? For example, if I make a sphere prefab I would need to generate Sobol distribution in some volume. EDIT Seyed Morteza Kamali have made a script
0
Animating child objects via parent object animator in script I'm using unity 5 I'm trying to animate multiple child objects via a parent object. The animation worked in the animation view but would not work when I tried to preview the game. In the script I use the code ParentObject.GetComponent lt Animator gt ().Play("intro") to play the animation. A similar line of code worked when playing a singular object, not sure what's going wrong now, any sugestions?
0
Unity Items not being removed from list So I finally perfected my RTS multiple movement. The situation is that the game objects are added into a list in a script bound to the camera called UnitController they are added from a unit client script MultiselectClient, this client accesses the UnitController class and adds itself the gameObject into the list. Each time I do the drag select I want it to clear the list first before adding any more. But for some reason, it doesn't work? This is in my UnitController (below) void MultiSelect(RaycastHit hit) Debug.Log(SelectedUnits) if (SelectedUnits.Count gt 0) Debug.Log("Moving group to " hit.point) foreach(GameObject gameObject in SelectedUnits) gameObject.GetComponent lt NavMeshAgent gt ().SetDestination(hit.point) This is in my client (below) public bool Selected false void Update() if (Input.GetMouseButton(0)) Vector3 camPos Camera.main.WorldToScreenPoint(transform.position) camPos.y Screen.height camPos.y if inside the cameras drag selection area then mark player as selected Selected UnitController.selection.Contains(camPos) Debug.Log("Selected") if(selected) addTo() void addTo() UnitController.SelectedUnits.Remove(gameObject) I have also tried .clear() which also hasnt worked. if (!UnitController.SelectedUnits.Contains(gameObject)) UnitController.SelectedUnits.Add(gameObject) Debug.Log("Added to list " UnitController.SelectedUnits) else Debug.Log("Im already in that list.")
0
Partial object culling without alpha transparency? I am trying to partially cull an object which has subsurface scattering. It's simple to do it with an alpha channel, however, using an alpha channel with transparency will disable subsurface scattering. Potentially relevant information I am using Unity 2018.3.0b12 with v4.8.0 preview HDRP Example here I am achieving the effect with alpha transparency. The object is either fully opaque or invisible
0
UniRx Subscribing to ReactiveProperty condition I'm trying to track a cold source with a contiguous range, and every example I've seen involves discrete increments or events that are already handled, so I'm vague on how to apply it. Here's what I have ReactiveProperty lt float gt CurrentAlpha new ReactiveProperty lt float gt (msg.GetComponent lt CanvasRenderer gt ().GetAlpha()) CurrentAlpha.Where(x gt x lt 0.0f).Subscribe(x gt Debug.Log( "CurrentAlpha CurrentAlpha Observed") img.transform.SetParent(null) Destroy(msg) ) I verified the alpha value, but never received notice when it reached 0. What have I mistaken? EDIT Found that it's actually subscribing to the value returned, which will always be 1. The value it receives is outside managed code, so there's no object property to observe, and CanvasRenderer itself doesn't observe it. Is it possible to observe a method's return value?
0
Unhandled Exception System.Reflection.ReflectionTypeLoadException The classes in the module cannot be loaded I am creating a project in Unity 5 free and using external dlls. I have a scene that is running normally within Unity but when I try to build the project as a standalone windows game I get this error which stops the build Unhandled Exception System.Reflection.ReflectionTypeLoadException The classes in the module cannot be loaded. at (wrapper managed to native) System.Reflection.Assembly GetTypes (bool) at System.Reflection.Assembly.GetTypes () 0x00000 in lt filename unknown gt 0 at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) 0x00000 in lt filename unknown gt 0 at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) 0x00000 in lt filename unknown gt 0 at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) 0x00000 in lt filename unknown gt 0 at Mono.CSharp.Driver.LoadReferences () 0x00000 in lt filename unknown gt 0 at Mono.CSharp.Driver.Compile () 0x00000 in lt filename unknown gt 0 at Mono.CSharp.Driver.Main (System.String args) 0x00000 in lt filename unknown gt 0 The following assembly referenced from C MyProject Assets Plugins MyPlugin.Unity.dll could not be loaded Assembly UnityEditor (assemblyref index 3) Version 0.0.0.0 Public Key (none) The assembly was not found in the Global Assembly Cache, a path listed in the MONO PATH environment variable, or in the location of the executing assembly (C MyProject Assets Plugins ). Could not load file or assembly 'UnityEditor, Version 0.0.0.0, Culture neutral, PublicKeyToken null' or one of its dependencies. Could not load file or assembly 'UnityEditor, Version 0.0.0.0, Culture neutral, PublicKeyToken null' or one of its dependencies. I guess there must be a mistake in the way the dll is loaded or something? What is causing this error? EDIT The Visual studio projects build properly with no errors
0
Unity move arrows along path I am not sure how to go about what might be a simple task. I want directional arrow sprites to move along a curved path in 2d to show the player when to go. I can use DoTween to create a path. But not sure if I should Instantiate a load of sprites(arrow) and move them along. Its seems wasteful.
0
How to find which side of a collider has been hit from hit.normal? In Unity3D, I can get the normal of the surface with which the collider collides using hit.normal, but is there a way to find which side has been hit with what is provided by Unity3D? One solution is to see the orientation of the normal, and should work well for static objects but what about dynamic and moving objects whose orientation changes?
0
How to connect Unity with Arduino using Bluetooth module? I will be getting data in real time from an Arduino. I want to display that data (such as rpm of a bike) in my Unity game and use it to control the subjects in the game. I have Bluetooth module HC 05 which I want to use to send the data from the Arduino to Unity. I found a plugin for this on Unity store but it costs 20. Could you guide me on how to include Bluetooth access in Unity as well as Arduino?
0
Using Reflection to access an array from a ScriptableObject in Unity I am trying to get access to a set of stored variables inside a scriptible object in Unity. This class (SectorDeclaration) has a method to pull a variable with a string of the variables name from it public Weightings GetVariName(string variableName) Type this class Type.GetType("SectorDeclaration") System.Reflection.FieldInfo fieldtype this class.GetField(variableName) Weightings fieldFind (Weightings )fieldtype.GetValue(null) return (Weightings )fieldFind Here's the error I'm getting TargetException Non static field requires a target System.Reflection.MonoField.GetValue (System.Object obj) (at Users builduser buildslave mono build mcs class corlib System.Reflection MonoField.cs 108) SectorDeclaration.GetVariName (System.String variableName) (at Assets Code Gameplay Element level Elements SectorDeclaration.cs 54) BaseGameManager.InitializeNPCSystem () (at Assets Code Managers BaseGameManager.cs 87) BaseGameManager.Start () (at Assets Code Managers BaseGameManager.cs 73) It works until the code reaches Weighting fieldFind (Weighting )Fieldtype.GetValue(null) I've used this code in another area but it is not working here, I've tried with System.object obj but it comes up with namespace doesn't contain this type, as well as with the type I am trying to access. Honestly, not sure what's wrong. If you need more information please let me know.
0
Unity Blender models animations showing gaps As part of a college project, a member of my group has made some simple chests with an open animation. Importing these into Unity though, I instantly noticed there were gaps where the faces should be. After a bit of experimenting, I figured it was because the Normals were facing the wrong way. The outside seemed fixed, but faces were missing when the chest opens during its animation. I'm guessing the inside of the chest will need another layer of faces with the Normals facing the right way...? Though surely this would means having doubles...?
0
Import blender camera with key frames to unity? I am wondering if I can take a camera tracked camera from blender and import it into unity. Is there any way to do this? Please let me know! Thanks in advance.
0
Unity Open offline web pages in a browser window by clicking a button? I currently have a Unity game where the user can click on buttons to open up web pages, I use the following script on the button for this... public void OpenURL(string url) Application.OpenURL(url) The URL is then put into the box that this script produces in the inspector and works perfectly. However what I would now like to do is open the pages OFFLINE instead, so people without an internet connection can see the information. The way I envisage doing this is to save the web pages so they can be opened up locally in a browser offline. However I am stumped as to how to tell the button to open the relevant file and open it is there a way of doing this? Maybe save the web page file in a local folder and point the button to that file? This would be way easier that the only alternative I can think of to save each web page as an image and have them open up as an image popup within the game as opposed to in the browser (there are a lot, so I would rather not have to do this!) This is for PC Standalone only. Any help would be greatly appreciated. Thanks in advance!
0
How do I activate a game action when a UI button is held? I want to make my button do stuff when the player holds it. In this case, I want to make a grab function when the button is down the character can grab objects, but if the button is up they do not grab it. I already have the function using the Standard Assets CrossPlatformInput. Here is how I have configured my button so far Here is my script void Update() Physics2D.queriesStartInColliders false RaycastHit2D hit Physics2D.Raycast(transform.position, Vector2.right transform.localScale.x, distance, boxMask) if (PushKey()) isGrab !isGrab if (hit.collider ! null amp amp hit.collider.gameObject.tag quot Box quot amp amp isGrab) box hit.collider.gameObject box.GetComponent lt FixedJoint2D gt ().connectedBody this.GetComponent lt Rigidbody2D gt () box.GetComponent lt FixedJoint2D gt ().enabled true box.GetComponent lt Rigidbody2D gt ().gravityScale 1 box.GetComponent lt Rigidbody2D gt ().mass 1 else if (!isGrab) box.GetComponent lt FixedJoint2D gt ().enabled false box.GetComponent lt Rigidbody2D gt ().gravityScale 6 box.GetComponent lt Rigidbody2D gt ().mass 6 public bool PushKey() return CrossPlatformInputManager.GetButtonDown( quot E quot ) With this function, the first tap on the button means quot grab activated quot and the second tap means quot grab deactivated quot , like a toggle. Instead, I want the grab to be active as long as the button is held.
0
"Breakout" script fails to trigger win after destroying the last brick The behavior I want is that when all the bricks are destroyed, the last brick's OnCollisionEnter2D handler calls SimulateWin(), triggering the next level. For some reason SimulateWin() is never called. using UnityEngine using System.Collections public class Brick MonoBehaviour public static int brickCount 0 public int maxHits public int timesHit private LevelManager levelmanager void Start () timesHit 0 levelmanager GameObject.FindObjectOfType lt LevelManager gt () void OnCollisionEnter2D(Collision2D col) timesHit Debug.Log("Collision happened with " col.gameObject.name) if(timesHit gt maxHits) Destroy(gameObject) if(GameObject.FindObjectOfType lt Brick gt () null) Not entering this if SimulateWin() this is never called void SimulateWin() This is the function that is supposed to be called when all the bricks are destroyed. levelmanager.LoadNextLevel()
0
How can I replicate Quantum Break's distortion particle effect? Quantum Break has this fantastic particle effect, it's a distortion effect like broken glass. I want know how I can replicate this effect? You can see it below, and a full video is available on YouTube
0
Serialize classes in unity c Is there some best practices to serialize objects to file on mobile devices in Unity using C . I've tried to search it myself, but found only this link. However, it looks like here they are trying to cache AssetBundles. I'm new to Unity, but I have some experience in iOS (swift) development. Here we have opportunity to cache some objects(variables) in local storage, to avoid overusing network. So I wanted to create some static class (for example Storage), which caches variables to file permanently and return them by some key.
0
how to check a condition for too many objects in a list that you dont know count of them I'm working on a defense game that I need a way of knowing if every enemy in a wave is dead. I wanted to use a counter for it foreach (GameObject g in group1) if(g dead) deadCount if(deadCount allEnemiesInWave) goToNextWave() but I think it's not a safe or accurate way. Is there any better way? Edit This question is not like Check if all gameobjects are destroyed. In my question, I wanted to make a condition on many objects, in the other one, OP wanted to check if such objects existed.
0
How to increase the difficulty setting as close as possible to maximum difficulty automatically? I have a simple 2D version of Mini golf. The goal is to manage to clear each level in the least amount of shots, the ball is bouncing at most 3 times (stops on the 4th hit) from a wall but not reducing in speed, there is no out of bounds and no obstacles that would remove the ball. Now I would like to add some water instant death obstacle at the most annoying places. How do I find those places? The player can aim in a 360 radius, if I set the goal of managing a given level in 2 shots, there are 129,600 ways of how the player could shoot the ball. While it should be possible to simulate all of those shots fairly easy, I don't want to add randomly water and check if the level is still possible to clear, rather simulate the level, record all places the ball went over and place on the spots with the most hits water. What is the best strategy a good algorithm to blockade the most ways but to guaranty that at least one way stays clear? Does the strategy change significantly if moving obstacles (on a fixed path, same rule for bouncing as normal wall) are included?
0
Creating a delay by using Invoke Is it possible to delay the effects of a script that is attached to a game object? I have 2 characters in a scene, both receiving live motion capture data, so they are both animated identically. I have rotated one by 180 degrees and placed it in front of the other one, to create the impression that they are copying mirroring each other. Each has several scripts attached to them, of course... Now, I would like to be able to delay one character a bit (e.g. 1 sec) to make it look more realistic, as if one character is observing the other character and then copying its exact movements. Is it possible to do this by somehow using the Invoke method on the other character's Update perhaps? Or any other possibilities to achieve what I described? EDIT I used a buffering mechanism, as suggested by all the helpful comments and answers, instead of delaying, because delaying would have resulted in the same network data being used, except after a delay, but I needed the same old data being used to animate a second character to create the impression of a delayed copying... private Queue lt Vector3 gt posQueue private Queue lt Quaternion gt rotQueue int delayedFrames 30 void Start() posQueue new Queue lt Vector3 gt () rotQueue new Queue lt Quaternion gt () void Update() Vector3 latestPositions Quaternion latestOrientations if (mvnActors.getLatestPose(actorID 1, out latestPositions, out latestOrientations)) posQueue.Enqueue(latestPositions) rotQueue.Enqueue(latestOrientations) if ((posQueue.Count gt delayedFrames) amp amp (rotQueue.Count gt delayedFrames)) Vector3 delayedPos posQueue.Dequeue() Quaternion delayedRot rotQueue.Dequeue() updateMvnActor(currentPose, delayedPos, delayedRot) updateModel(currentPose, targetModel)
0
Why does Unity require an EventSystem component for input during a play test, where input works fine without it in a build? Please be aware that this was initially a question about how to get the input to work. A comment pointed me in the direction of a fix, but only left me with more questions in regards to understanding the problem I was originally having, so I have edited my question to include the initial solution and focus on the question I still have. The Problem Recently, I have moved from using GUIText and GUITexture objects to using the Canvas to display UI elements. In effort to set up a prototype, some external GUI elements were imported, and when the game is built and run from my phone, everything works as intended. However, if I simply run the game from inside Unity, input is completely ignored. I originally thought this may have been a response to grabbing touch screen input, and expecting it to work on a regular screen with mouse input, but I have since confirmed that it still does not work when using Unity Remote to test the game on my phone. It has since been pointed out that I was not using an EventSystem, along side my Event Trigger objects. After implementing an EventSystem component, and the default input module supplied by the EventSystem interface, the input works. However, this still leaves me confused. What is the point of enforcing the implementation of the EventSystem, if it only ensures functionality during play test? Why would I want this system in my end build, when I can confirm that the build version functions properly, without it? Below you will find my setup, contextual to the problem. Click for a zoomed in view, as I have included the component structure of my UICanvas and MainCamera objects, in case it is helpful. In this case, we have a button that increases the max speed, when pressed. Everything works in a build, but nothing works during a play test. Additional Information I have enabled 'show touch input' on my phone, to confirm that the phone is still registering touch input. I moved to using the Canvas object after the 'depreciated warning' for using GUIText and GUITexture turned into a 'depreciated error'. Even if there is a suitable way to still perform these actions with the GUIText and GUITexture objects, I still wish to persist with using the Canvas. I am also personally curious as to why this issue exists within the Canvas, as it seems lead to obvious cases of severe inefficiency, in a system that seems to have been put together with the sole point of being more efficient. I can create manual OnMouseDown buttons that will work during play test, however, some GUI elements are more complex and persisting with this sort of solution seems like an incredible waste of time. As previously mentioned, I do not have any input issues if I simply build and run the game from my phone. However, this takes considerably more time than a simply debug test, and even without the high efficiency cost, I do not have access inspector manipulation during my play test. I am using Unity version 5.3.5 personal. Any solution that does not include updating Unity will be well preferred. While I have no physical problems updating Unity, in some previous projects updating Unity versions has lead to massive issues that we would prefer to outright avoid, if possible. TL DR Unity will not accept input on my input canvas during debug. I literally have to build and run my project each time I want to test input, or create dodgy hacks to provide input from the Inspector. The addition of an EventSystem allows input during debug play testing, but is not needed for input post build. Why does Unity act this way, and why do I need an EventSystem entirely for play test input?
0
How can I write an additive mesh shader that splits the RGB channels while accounting for depth? I'm trying to create a sort of "hologram" effect. So far, what I have is an additive, three pass shader that uses ColorMask for each pass to separate the RGB channels. The problem is that doing so requires ZWrite to be off (first image) so that each pass doesn't intersect the others (second image). However, doing so means that the model geometry overlaps itself, which I don't want. I've tried the various methods of taking depth into consideration with transparency (This, for example) but they all cause problems when trying to separate the RGB channels. Is there some way to have each pass take depth into consideration within itself, but not with the other passes?
0
How to merge VRPN and Unity I'm new to virtual environments, having worked mostly with Arduino and other physical applications. I'm trying to set up VRPN server on one of the computers in my lab to pass some triggers from a Unity game to a VR environment and there is little to no documentation that a novice can at least hack through to explain how VRPN even works. Can anyone shed a little light on it and explain how to set up a VRPN server using c ?
0
(Why) Should I choose Unity 3 or Cocos2d (or something third) for my app? My colleague and me made an HTML 5 iPad game ( http braille.gandzo.com ) and we would like to upgrade it, and our framweork is not enoguh, for what we want. Some of the things we would change are graphics update, animations "effects", multi player, achievements and so on. The game would stay 2d. Now, as far as I understand, both Unity and Cocos would be good for this task, with Unity having the advantage of being multi platform. What I want to know is are there unknown qualites "flaws" to these two programs which would influence my decision (maybe even by choosing something else). Examples that come to mind are "Unity is too complicated has too much unneeded options hoops because it's made with 3d in mind" or "Cocos is significantly more suited for 2d games".
0
What's the best way to make a game launcher? I am a new game dev, and would like to make a launcher for my games. All my games would be in ONE launcher, and it'd be similar to the Minecraft Launcher. I wanna do it for free too. The main reason I wanna do it is to update my games. I don't have a file server, so the files would be on Google Drive. Thanks!
0
My cube goes through side walls on android device I have a cube and it's on the ground and there are two walls (Plane) next to the ground. Like in the image there is a ground and in side there is a wall. Here is my code void Update() transform.Translate(userDirection speed 14f Time.deltaTime) transform.Translate(mSpeed Input.GetAxis("Horizontal") 2 Time.deltaTime, 0f, mSpeed Input.GetAxis("Vertical") 2 Time.deltaTime) if (Input.touchCount 0) return Touch touch Input.GetTouch(0) float originalY transform.position.y float cameraZ Camera.main.WorldToScreenPoint(transform.position).z if (touch.phase TouchPhase.Moved touch.phase TouchPhase.Began) Vector3 screenPoint new Vector3(touch.position.x, touch.position.y, cameraZ) Vector3 worldPoint Camera.main.ScreenToWorldPoint(screenPoint) worldPoint.y originalY transform.position worldPoint My cube goes through the side walls, but on laptop it works perfectly, and on android device my cube goes through the side walls. Can anyone please tell why is my cube is going through side walls? Any help is appreciated!
0
Why the skyline continues to stay on the same place and how to change this? I started my first Unity3D project and in this game main hero should be able to fly up passing clouds and then reaching open space but i faced with the problem. No matter how long and fast i am flying after takeoff the skyline continues to stay on the same place. Currently i'm going to rotate the main hero so that skyline would go down. But maybe someone can suggest me more common and better way to achieve the effect of leaving the Earth? I think it would be bad idea to post all my code here because there is a lot of code that does not relate to the topic. But i will try to explain what i'm doing now and i will show you short piece of code. I have global parent object and a main hero is added as a child to it. Then when as main hero moving up relative to the global object i start to rotate this global object around z axis so that gradually the main hero is looking to the sky. And for skyline i'm using procedural skybox. I hope this piece of code will explain better of what i'm doing now using UnityEngine using System.Collections using UnityEngine.UI public class PlayerController MonoBehaviour float gravity GameObject global main hero s parent Vector3 startHeroLocalPos start hero position relative to the global object public float degreesPerUnit 1.0f global object will rotate by this amount of degrees after the player has moved up by one unit void Start () global GameObject.FindGameObjectWithTag ("GlobalObject") startHeroLocalPos transform.localPosition void Update () float curAngle (transform.localPosition.y startHeroLocalPos.y) degreesPerUnit global.transform.rotation Quaternion.AngleAxis(curAngle, Vector3.back)
0
Unity3D multiple objects user rectangle selection I wish to allow the user to select multiple units by click and drag as most RTS do. The issue I have is that the tutorials are either in 2D or only use the transform.position such as this one. Using the transform.position will work for most cases but will not allow the user to select easily as selecting the head or feet of a unit will not work in this instance. It also means I have to do an other script using raycasts for single click selections as it is almost impossible to get the single point of the transform.position with one click. How can I do a proper rectangle selection for a 3D game? By looking at 3D RTS games I own, I noticed that they use a simplified hitbox (usually a cube or capsule).
0
Smooth rotation for a bone? I'm trying to make my character bone "chest" rotate smoothly when face enemy and get back to his stand. Can anyone help me with this ? public Transform Target public Vector3 Offset Animator anim Transform chest public float rotation speed public bool aim at traget false void Start() anim GetComponent lt Animator gt () chest anim.GetBoneTransform(HumanBodyBones.Chest) void LateUpdate() if (aim at traget true) smooth rotation to face target chest.LookAt(Target.transform.position) chest.rotation chest.rotation Quaternion.Euler(Offset) else get back to you stand smoothly
0
Moving lights or scene objects in Unity seems to cause a second point light to shrink or dim Moving a Point Light in 2d space seems to be dimming lights around it. What is this and how can I solve it?