_id
int64
0
49
text
stringlengths
71
4.19k
0
unity 5 how to get a shadowmap I'm writing a custom shader in unity 5 that requires a shadowmap (not just for drawing shadows but also for different computations involving scattering particles through fog). Does anybody know how to actually get the shadow map in unity rather than just using the fallback option? That is including the actual Z buffer not just the resulting 1's and 0's. I could also use the depth buffer from the camera but that only appears to apply to camera used by the player rather than the second one I can add to replace the light (inside the light).
0
Display hide image with zoom in out After spending a while looking through the forums, I haven't been able to find a thread that deals with transforms on an image. Essentially, what I'm trying to do is display and hide an image at the start of a level in a game I'm working on. The image should start out large and with 100 transparency, then shrink to a certain size within the camera bounds with no transparency, idle for a second, then fade back out the way it came. How would this be done programmatically? Thanks in advance!
0
Unity sprites and layouts I am trying to learn Unity for a simple board game. The question is, is it possible to use grid layout group (or any layout component) with sprites? The goal is to fit a board into my view regardless of the aspect ratio of the device. The following grid should contain 7 by 7 sprites and it should scale up and down (no more then lets say 100 px) and have an aspect ratio of 1. I've tried adding a canvas and a panel that has a grid layout group component but it seems like sprites are not affected when added to the panel. Also it seems like when I try to work with a panel or a canvas they have a fixed sizes in units. Having fix sizes feels a little bit off. Is there a way to use layout components so sprites can have relative distances between them. So far I am stuck and lost in tutorials and feeling like the answer should not be this complicated. Any push to the right direction is welcome.
0
Importing audiofile into Unity3d gets shown after ending playmode I am working on a game where the user has the possibility to import custom audio tracks that can be listened to during the game. For this I am making use of System.IO.File.Copy method. This works, there are no issues or flaws here. When I inspect the target and destination folder the file(s) get copied properly and show up in the folder. The issue however is that the Unity Editor doesn't show the file despite it actually being there. During play mode in the Unity editor the new file isn't shown in the resources folder (which I use as destination for now). When I use windows file explorer I can clearly see the file in the corresponding folder. Using debugs (in Unity) also state that the folder is empty, however when I use debugs outside of Unity it shows that the folder contains the copied item. Keep in mind that these both debugs are called roughly at the same time. I have tested this in many ways to be 100 certain that Unity doesn't see the file, while it is there. So once I stop playmode it starts loading importing processing the new file and then it shows up in the folder in unity as well. When I launch playmode after this the file is indeed loaded and included in the game as well. I however need this to happen without having to stop playmode. So there is probably some type of processing that I haven't called for Unity to process the addition of the new file and for it to be visible. So in a nutshell basically copying a file from folder to folder isn't enough for Unity to directly utilized in the same play session (and all after). How can I make the audio file directly showable and accessable? There aren't any errors or warnings. The file plays correctly after it has been processed. I am at a loss with this issue bug.
0
How can I use Drag handlers (IBeginDragHandler, IEndDragHandler, IDragHandler) with a 2D sprite renderer instead of a UI Image? In my game, I assigned all of the blocks to be 2D sprites so that they could be easily converted into prefabs However, when designing the drag and drop scripts, I noticed that all of the drag and drop handlers such as IBeginDragHandler, IEndDragHandler, IDragHandler, etc. weren't working at all. I later noticed that these were intended to be used by UI Images. Now I am left wondering what I can do to make these 2D Sprites be usable by these functions for UI Images. Do I have any other options other than to start from scratch by making new UI Images? Here's the small amount of code needed to create a reproducible example Public class DragDrop MonoBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler SerializeField private Canvas canvas private CanvasGroup canvasGroup private RectTransform rectTransform private void Awake() rectTransform GetComponent lt RectTransform gt () canvasGroup GetComponent lt CanvasGroup gt () public void OnBeginDrag(PointerEventData eventData) canvasGroup.alpha 0.6f canvasGroup.blocksRaycasts false public void OnDrag(PointerEventData eventData) rectTransform.anchoredPosition eventData.delta canvas.scaleFactor public void OnEndDrag(PointerEventData eventData) canvasGroup.alpha 1f canvasGroup.blocksRaycasts true
0
Unity Load Lightmaps at Runtime I'm a bit of a novice to lighting, but I think what I want to do is possible, so please bear with me. Due to the nature of my game, I've taken an approach where a singular scene game is where all of the gameplay occurs. For each level, I'm arranging all the GameObjects and Terrain in a secondary scene (named testbed) to my liking. Once I've got it to my liking, I save that to a prefab, which in turn is saved to an AssetBundle. I also generate the lighting at this point, which I can see appear in my project under a Assets Scenes testbed folder. At runtime, a script in the game scene reads the appropriate AssetBundle, and then loads amp positions all of my objects and characters. Everything about this works, except for updating the lighting. My approach is to store references to the lighting textures that have been output into the aforementioned testbed folder via a ScriptableObject (after trying and failing to use the LightingData object that appearred in this same folder) Then, when I'm loading my level up into the game scene, this block is executed public void LoadLighting(LevelKey key) var data levelMap.metaData.Find(it gt it.key key) var directions data.lightData.directions var lights data.lightData.lights var lightmaps new LightmapData directions.Length for (int i 0 i lt directions.Length amp amp i lt lights.Length i ) var lightmapData new LightmapData() lightmapData.lightmapDir directions i lightmapData.lightmapColor lights i lightmaps i lightmapData LightmapSettings.lightmaps lightmaps Based on a lot of searching, this should cause something to happen, but I can't detect any change in the scene. Does what I'm trying make any sense? Should I just scrap this and make dozens of different scenes (which I'm trying to avoid) instead? Really any advice here is appreciated.
0
How can I send Android notifications from my Unity game? I'm want to send local notification on Android with Unity3D but I don't know how to do it. Any suggestions?
0
Configurable Joint, linear limit range I am working on a physics driven pressable button, but I cannot seem to tackle the minimum and maximum limits. This is the rig I have set up for the button (as it looks when pressed down). 2D view 3D view The idea is that the box collider is a trigger and the button (cylinder, mesh collider) is a rigidbody with configurable joint, locked and limited on a single axis. I am using configurable joint, as that's the only one that supports basic, linear restrictions. I have set up the configurable joint to restrict motion on a single axis, but the joint only allows single dimensional limit, that is applied to both directions. Screen capture of relevant configuration Basically, the opened Linear Limit section is the last property that has been changed for the joint anything else are defaults and irrelevant (at least I haven't found my solution in the properties below, mostly angular stuff). The limit of 0.2 units work, and the button can be pressed it only gets pressed until those 0.2 units and thats the expected behaviour. The unexpected is that sometimes the angle at which I hit the button, adds force to the button outwards from the box, and it moves 0.2 away from it, ending up like this Obviously, the specified limit of 0.2 units constrain the movement in both directions from the anchor, actually resulting in the range of 0.2 to 0.2 (relative to anchor). How, and is it even possible, to restrict the movement only in a single direction relative to anchor?
0
Making a scriptable dynamic Distance Joint in Unity I have 2 2D RigidBodies that are connected together using a Distance Joint 2D... I update the distance of said Distance Joint 2D (using a script) expecting the distance between the two RigidBodies to change, but nothing actually happens. I'm guessing this is to do with the Physics engine not updating the positions of the RigidBodies?
0
Strange issue with bool comparing ToString always false unity c I have another problem with my code that I can't fix Basically i have an enum called 'type' in my Item class, which tells me if the item is consumable, or equipment, etc. In the database script I have made, it sets the type for each item (5 in total). So basically I have an inventory UI, with 5 items (inc. 2x consumables, 3x Equip) After much debugging checking things, I've found that the boolean prior to "sortedItems.Add(i) " is always FALSE. But it shouldnt be, BOTH VALUES ARE THE SAME as per the console log. I have input a print() line to check whats going on because my items are'nt sorting by type when I expect them to. public void SortItemsByType(string type) sortedItems.Clear() foreach (Item i in allItems) print("is the following true or false" i.type.ToString() type) print("this is iToString " i.type.ToString()) print("and this is type " type) if (i.type.ToString() type) sortedItems.Add(i) and (please note the 3 print lines, here is their output in the console (sorry but the dumb IDE won't let me copy paste the console, here is image) Im still very much a noob to this, so I am sure there is something I have missed. But for the life of me i cannot figure out why that bool is always resulting in FALSE? Any help is massively appreciated. Thanks
0
Whats the least expensive way to play video in unity? Alright, Ive asked this various ways but my situation is I have several (over 100) objects that have screens that need to play animated videos on them. There does not need to be sound, but this is for VR so performance is an issue. So far, after trying render textures and video materials and seeing that fps dropped, Ive been using this script to flip through sets of pngs and put them in the diffuse slot of a material public class VideoPlayerRawImage MonoBehaviour public Texture frames public int framesPerSecond 60 public bool isEmissive false void Update() int index (int)(Time.time framesPerSecond) frames.Length this.GetComponent lt Renderer gt ().material.mainTexture frames index if(isEmissive) this.GetComponent lt Renderer gt ().material.SetTexture(" EmissionMap", frames index ) if(index gt frames.Length 1) index 0 Is this the most efficient way to play videos? What would be a drawback to this method is there a better way?
0
How can I use shaders in Unity to write a scientific computing program? I want to write a GPU shallow water code on Unity3D. For sure, performance matters a lot. I've done this before using DirectX and C . But for a couple of reasons I want to redo it in Unity3D. I have some hands on experiences with Unity3D, but I have no idea how I can write GPGPU codes, like what I did in DirectX. In DirectX I am using textures as my data structure for the properties of water cells (height, x velocity, y velocity, etc.) and HLSL shaders as my parallel computational functions (kernels). Furthermore, I prefer my code to be near cross platform. Is it possible to do something similar in Unity3D using OpenGL? I am an engineer, and not a game developer, so please keep it simple ...
0
Create a seemless grid based polygonal tileset The aesthetics I am going for is demonstrated by many simulation games such as Simcity. But I am looking at this particular example Polygonal Planet Project by Oskar St lberg. I understand the concept when the player places or upgrades a tile, the game looks at adjacent tiles to figure out which tile should be used. And in most cases, a tile would be self contained, so I just need to design all possible variant of such tile. And I have some experience on procedural generation in 3D, so coding isn't the main problem for me. What I am wondering, are Does this type of continuous 3D tilesets have a name? I tried to google some examples tutorials but failed to find the appropriate keyword. Are there tools to make the process of creating tile variants easier? Is there a preferable process to create such tileset? Do I start by creating structures then divide them into repeatable patterns, or should I start with basic tiles and find way to create smooth transition between them? That's probably too much to answer in detail, but I would like some pointers on this topic (more about asset design than programming I suppose). Thx!
0
Having trouble combining clampMagnitude and some explosion force I have a character that uses rigidbody, and I am using AddForce() to make it move. And so I do rb.velocity Vector3.ClampMagnitude(rb.velocity, maxSpeed) to limit diagonal speed. Yes that did worked but my problem is adding for example explosion force. So if explosion force is very high, it will still clamp the velocity of the player. What way should I use to combine movement that limits diagonal speed and a properly working explosion force toward the player. At least give a clue how can I do it? My only main problem here is the way that I implemented to limit diagonal movement. I wanna improve that by not using Vector3.ClampMagnitude() so the AddExplosionForce() will work properly to the player. Because clamping magnitude of the player will also limit the velocity when it is affected by the explosion force. So can anyone give a clue how can I implement to limit diagonal movement without using clamp magnitude? I thought about normalizing the move like Vector3 move transform.right x transform.forward z move move.normalized Time.deltaTime moveSpeed But I realized I am using AddForce(). Even though I limited the diagonal speed, it will go faster and faster because there is no maxSpeed. Help please.
0
Blend trees does not get effect on some animations I have created generic animations in unity where bike rotate to its left or right depending on what axis user is pressed. I have created several right turn animations though out of those animations,only couple of work when blend tree parameter gets changed.Other remain same and does not effect bike. When I use "loop" to true in other animations ,it do work but loops continuously. I am using only one right anim at a time. Plz help in
0
Advice on Story Text Based Game I am currently in preparation on making a game. This game will be looks like Lifeline by 3 Minute Games, which is a story text based game. My game will have the same concept with it. Where there will be a scrollable history of conversation between player and characters in game. However, my game will has more than one conversation history. He will be able to interact with more than one character. Therefore, when the game start, it will show list of interactable characters in game, and player can choose who he will interact with when any available. I am planning to make it with Unity. But I don't know is it possible to create some scrollable history of text, each with different content, like chat history, in Unity. So I wanna ask your opinion, is it good to just continue with using Unity, or should I change the game engine I use? If I should change, what is the best game engine to cope with this kind of game? Thank in advance )
0
Box collider pushes me out of it's area slowly, I can pass through it if moving quickly I am new to Unity. I Setup a character in unity2D with a rigidbody. I had the scale off my sprites set to 100 pixels per unit. At this scale, my rigidbody character stood on top of platforms and could not pass through walls containing box colliders. I decided, that to make things easier, I would change all sprites to 1 pixel per unit. After doing so, I scaled everything (variables, sizes, etc.) by 100. I confirmed that the box colliders on both the caharcters, floor, and walls, are all in the same places, relatively. The box colliders on the floors still work, but the wall box colliders behave differently. When I walk into a wall, the wall slowly pushes me in a direction (depending on whether or not my character has walked through half the wall or not). The wall should be stopping my motion completely. The code is very simple, but this is what I use to move if (Input.GetKey (KeyCode.D)) transform.Translate (Vector2.right moveOffset Time.deltaTime) transform.localScale new Vector3(1,1,1) anim.SetBool("moving",true) Do note that the moveOffset variable, was scaled by 100 after the change. Thanks in advanced!
0
How to make rhythm game long notes in Unity? I'm making a rhythm game for a university course and I can't figure out a way to make the long sustained notes. For reference, this is what I mean taken from Guitar Hero I already have a system working for regular notes. The way I do it is that the notes are stored in an external file as numbers which represent the absence or presence of a note as well as what type of note it is, separated into musical bars 000 010 020 001 There are three lanes for the notes to be, and this means that in this particular bar there are notes wherever it's not 0 (with the numbers being different types of notes). I had thought of using this system to create long sustained note start and end markers (say 3 and 4) and that create another game object which would be the line between the start and end markers. But the way my note generator works is that the notes are not all generated at once because that'd be pretty heavy. Instead, the notes are generated at a certain time taking into account its speed so that it's instantiated and will reach the player's activator when it's supposed to. The following is a part of my note generator code, put in the Update method if current song time time offset is greater than time taken for all executed bars so far spawn the next bar's notes if (songTimer timeOffset gt (barExecutedTime barTime)) StartCoroutine(PlaceBar(noteData.bars barCount )) barExecutedTime barTime And here is the PlaceBar coroutine go through all notes in a bar creates an instance of note prefab depending on which note is meant to be spawned private IEnumerator PlaceBar(List lt SongParser.Notes gt bar) for (int i 0 i lt bar.Count i ) if (IsThereNote(bar i .bottom)) GameObject obj (GameObject) Instantiate(GetNotePrefab(bar i .bottom, true), new Vector3(bottomLane.transform.position.x distance, bottomLane.transform.position.y, bottomLane.transform.position.z 0.3f), Quaternion.identity) if (bar i .middle ! 0) GameObject obj (GameObject) Instantiate(GetNotePrefab(bar i .middle, false), new Vector3(middleLane.transform.position.x distance, middleLane.transform.position.y, middleLane.transform.position.z 0.3f), Quaternion.identity) if (bar i .top ! 0) GameObject obj (GameObject) Instantiate(GetNotePrefab(bar i .top, true), new Vector3(topLane.transform.position.x distance, topLane.transform.position.y, topLane.transform.position.z 0.3f), Quaternion.identity) yield return new WaitForSeconds((barTime bar.Count) Time.deltaTime) So if I were to make start and end markers, the start marker would not know where the end marker is because it doesn't exist. Could anyone help please?
0
Does Transform.childCount not work correctly? This is my code void OnTriggerEnter(Collider collide) if (collide.gameObject.transform.tag "Laser") Debug.Log ("Inside If") Transform resourceTransform collide.transform Transform tf new Transform resourceTransform.childCount for(int i 0 i lt resourceTransform.childCount 1 i ) tf i resourceTransform.GetChild(i) Debug.Log ("Child Count Before " resourceTransform.childCount) resourceTransform.transform.DetachChildren() Debug.Log ("Child Count After " resourceTransform.childCount) Vector3 centerOfMass resourceRb.centerOfMass Explode (tf, centerOfMass) Everything is working fine, except the childCount property is always zero and that screws everything else up. Here's an image of the hierarchy The script is on cube1 and the object has 12 or so children. So why is childCount equal to zero? Is it a problem with Unity itself?
0
accelerometer not working unity why is the cube moving when I use a controller, but not with the accelerometer? void Update () text.text "X " Input.acceleration.x " Z " Input.acceleration.z transform.position new Vector3(10 Input.acceleration.y, 0, 10 Input.acceleration.z) transform.Translate(Input.acceleration.x, 0, Input.acceleration.z) transform.position new Vector3(10 Input.GetAxis("Horizontal"), 0, 10 Input.GetAxis("Vertical")) transform.Translate(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) (I'm on a Xperia Z3 compact by the way)
0
How can I play a particle system only when it's visible? I am making a game and it has a lot of particle systems in it as special effects, and all of them are supposed to be playing at the same time, but doing that will be heavy on the game's performance, then I thought Is it possible to play a particle system only when it is visible to the camera and stop playing it when it is out of range or hidden from the camera, maybe with physics raycasting? If it is, can someone help me to write codes that will do so.
0
How do I apply domain warping to my marching cubes voxel terrain in Unity? So, in GPU Gems 3 there is a cool warped terrain that I seek to replicate. Currently, I'm generating the terrain fine, but I want to add that warp effect. Do this before using 'ws' to sample the nine octaves! float3 warp noiseVol2.Sample( TrilinearRepeat, ws 0.004 ).xyz ws warp 8 Im wondering how to replicate the above code in C . What does the above code do? What type of variable is noiseVol2.Sample(x,y).xyz? I want to warp my own terrain, currently I have a system that creates octaves of perlin noise with certain frequencies and amplitudes. It looks something like this var perlin0 new Perlin3(0,baseFreq 4.03f, 0.25f) var perlin1 new Perlin3(1, baseFreq 1.96f, 0.50f) var perlin2 new Perlin3(2, baseFreq 1.01f, 1.00f) var perlin3 new Perlin3(3, baseFreq 0.49f, 2.00f) var perlin4 new Perlin3(4, baseFreq 0.24f, 4.00f) return new Density(ws gt start with plane float density plane.Evaluate(ws) add perlin noise to get density values at each ws co ord. 3 octaves currently (3 perlin noise ) density perlin0.Evaluate(ws) density perlin1.Evaluate(ws) density perlin2.Evaluate(ws) density perlin3.Evaluate(ws) density perlin4.Evaluate(ws) return density ) I've tried replicating it like so var q new Vector3(perlin0.Evaluate(new Vector3(0,0,0)), perlin0.Evaluate(new Vector3(5.2f, 1.3f, 1.3f))) var q1 new Vector3(perlin1.Evaluate(new Vector3(0, 0, 0)), perlin1.Evaluate(new Vector3(5.2f, 1.3f, 1.3f))) var q2 new Vector3(perlin2.Evaluate(new Vector3(0, 0, 0)), perlin2.Evaluate(new Vector3(5.2f, 1.3f, 1.3f))) density perlin0.Evaluate(p 4.0f q) density perlin1.Evaluate(p 4.0f q1) density perlin2.Evaluate(p 4.0f q2) I've read the article that igo Qu lez created, and implemented it like above. Am I doing something wrong? It looks the same without that, just using density perlin0.Evaluate(p) density perlin1.Evaluate(p) density perlin2.Evaluate(p) I want to know what I'm doing wrong, what I misunderstood and how to implement it correctly. This is all based off this lumpn's proceedural generation on github (I would link it, but I can't) Thanks. I would also want to know if there are any examples (I learn best from codebases) with this implementation using shaders. (Maybe it will run faster because it uses the GPU instead of the CPU?) This is still unanswered on how to do it on the CPU (and I'm still confused on how to do it on the GPU, do you have to do some vertex stuff? how do you pass in a noise texture through the shader?)
0
Console spam when opening editor Assertion failed on expression 'txn.Exists(guid)' I have just opened up a new project in Unity 2019.3.04b and in the console I got an error message repeating a lot of times In addition, when unfocus and focus Unity, it spits out one more pair of errors (the same errors like in this image). Anyone knows what it is and how to fix it?
0
Show procedural map without running the game? Currently I have a script that generates prefabs by code and I'm wondering if I could show a certain "seed" of that map without actually running the game. The reason why is that I often want to tweak things, and when I run the game and alter settings for objects like lights they get reset when I stop running the game and perhaps have some kind of button where I can reset the seed and see another generation of the map.
0
Why does my collider behave strangely after a coroutine So I'm trying to create a simple script that is going to handle the logic for cutting down a tree I'm experiencing some strange behaviour with my script. I have a private field which holds the quot HP quot for the tree which starts at 100, and when I hit the tree it goes down by 25 every time, so I need to hit it four times in order for me to cut it down. Once the tree reaches lt 0 in terms of HP it should play an animation which simulates the tree being cut down, wait a couple of seconds and then play another animation of it appearing again. Most of this works fine, it's not until after the animation, where I start my CoRoutine to wait for a couple of seconds it starts messing up. ISSUE The first time I cut it down, it works fine.. However.. After it respawns I need to hit it like 4 5 times for it to go down to 50 health and then it works like normal. So I hit it once, it gets to 75, I hit it twice, still at 75, 3 times.. still at 75.. And eventually, it starts going to to 50, 25, 0 etc.. This only happens after I cut it down the first time, and the first time it works fine. Here is my Tree script NormalTree.cs public class NormalTree MonoBehaviour public static NormalTree instance private int health 100 public Animator animator private void Awake() if (instance null) instance this animator GetComponent lt Animator gt () private void Update() if (health lt 0) KillTree() private void KillTree() StartCoroutine(TreeSleep()) IEnumerator TreeSleep() animator.SetBool( quot treedead quot , true) gameObject.tag quot DeadTree quot yield return new WaitForSeconds(3f) animator.SetBool( quot treedead quot , false) gameObject.tag quot Tree quot health 100 public Item DamageTree(int damage) health damage Debug.Log( quot Tree health health quot ) if (health lt 0) return new Item Amount 1, ItemRarity Item.ItemRarityEnum.Gray, ItemType Item.ItemTypeEnum.Log else return null And in my PlayerController I have this, which essentially checks if my hitbox collides with an object that has the tag quot Tree quot private void OnTriggerEnter2D(Collider2D other) if (other.CompareTag( quot Tree quot )) var wc Skills.FirstOrDefault(x gt x.Name quot Woodcutting quot ) var tree other.GetComponent lt NormalTree gt ().DamageTree(25) if (tree ! null) inventory.AddItem(tree) wc.AddExperience(25) Debug.Log(wc.Level)
0
Unity UI button not triggering custom script function I have created simple movement buttons in my game. They should trigger functions of the player's scripts, but I can't link the button to the player object script canonically from the inspector 'cause the player is created at runtime. So I created a custom script attached to the buttons using UnityEngine using UnityEngine.UI using System.Collections public class ActionButton MonoBehaviour private Button btn void Start() btn GetComponent lt Button gt () btn.onClick.AddListener(TriggerFoo) public void TriggerFoo() Debug.Log("Btn triggered!!!!") Haven't implemented yet the behavior I want to achieve with it, but even at this point the button doesn't print the string on console. Here is how the button is set up in the inspector I am missing something very obvious here....?
0
OnCollisionEnter2D incorrect contact point? I am trying to shoot a bullet (rigidbody2d, boxcollider2d) to another enemy object (rigidbody2d, kinematic, circlecollider2d). I want the collision point between these two. When they collide, i want a collision particle effect and from the contact point, i want to create 5 rock objects all moving in different directions. How should i achieve this? Problem is that, the contact point i get seems incorrect. Collision particle effect is created when collision happens but the rock objects are created in some other point close to the contact point but not the contact point. Also how to i move the rock objects in different directions after instantiating them? my code void OnCollisionEnter2D(Collision2D coll) if (coll.gameObject.tag "Enemy") ContactPoint2D contact coll.contacts 0 GameObject rock1 Instantiate (rock, contact.point, transform.rotation) as GameObject rock1.rigidbody2D.velocity transform.up 20 GameObject rock2 Instantiate (rock, newPos, transform.rotation) as GameObject rock2.rigidbody2D.velocity transform.right 20 Destroy(coll.gameObject) Destroy (gameObject) Instantiate (explosion, transform.position, Quaternion.identity)
0
Having trouble with getting an image to fit on a face of a cube I have a problem with a Unity project that I'm working on. I'm creating an 3D art gallery which will be developed into a VR application in the future. In a 3D scene, I have created a paint canvas GameObject (a cube) but I have some trouble getting images fit on the whole canvas. When I try to apply an image as a material, it is treated as a texture and only a small part of the image is visible on the canvas. I am planning to make a UI where the user can upload pictures and the application will automatically render the gallery with these pictures.
0
How to make an authoritative multiplayer game deterministic for all clients? I'm starting to create a multiplayer online game, with an authoritative server. As it is, the clients send inputs to the server which do the simulation and then send back to clients the updated state. The game is a top down shooter, so it's fast paced and input lags are not allowed here, so to avoid this I'm doing the simulation on the client too, and when the server update come back I compare the local simulation with the server response. If they are compatible everything is fine, otherwise, the client version is corrected. I was expecting that the client simulation desync at some point, because of all of the variables on physics, floating points, network etc... But this happens much more than I thought. Just by sending the inputs and simulating on the server, the results are very different, even on simple movements, like forwards and backwards on a clear space. Green is local, red is server response I need help on this step, a way of keeping, at least this kind of simple movement, consistent on the server and the clients.
0
Unity3D 3.5 pro Moving the camera vs setting draw distance I move the camera mostly via right click WASD, sometimes with shift if I want it to move faster. Occasionally, instead of moving my camera, it alters the draw distance FOV some visual aspect of the editing scene that causes trees and other object to disappear when I scroll enough, and eventually even the terrain starts disappearing. It is not m "zooming out". My camera does not move, the width and height of the FOV stays the same (one might say the depth is being altered though). What key am I hitting to cause this to happen, and is it possible to disable it? side note "keybinds" is probably the most spot on tag for this question but it doesn't exist (surprisingly) and I lack the rep to create it.
0
Convert a modified Transform.forward to world space I am trying to make an electricity system, where it is given the start and end points, and it works out a random sequence of points in the rough direction of the end point. These points are set as vertices on a line renderer, and it should end up joining up as a bolt of electricity. My problem is that it needs to move 'forward' from start to end. The easy solution is that the electricity comes from a game object, which is set to LookAt the end point. Then, every time it sets a 'nextPoint', it adds to the transform.forward. nextPoint new Vector3 ((startingPoint.forward.x divergence.x), (startingPoint.forward.y divergence.y), distance) divergence is a Vector3 containing a random increase on the x and y axis, and 1 on the z axis. This works, in a way. The problem is that it then assumes these are world space coordinates. So the line will go from starting point, to (eg. 0.3, 0.75, 1), and then back to the end point. I can't find a localToWorld conversion for a vector though, so I am not sure how to get the transform.forward whatever, converted from local to world space.
0
Using State Pattern with Unity I am new to Game Development and Unity. I have written a component for Jumping and Running, CharacterJumpAbility.cs and CharacterRunAbility.cs. I would like the Character to be able to Jump only if the Character is not moving. I came across a State Pattern but I can't understand how to apply it. For example if I want to Jump, first I must check if the Character is Running, but I have to do this in the CharacterJumpAbility.cs or in the CharacterController.cs (the component who handles inputs)? If I define a state for example public enum CharacterState Run, Jump For example if the player is pressing the space bar, I have to set the Jump state, the code that sets state CharacterState.Jump should be written in the CharacterJumpAbility.cs or in the component that handles inputs? And if I want to set a new state for example Jump, while I am running, this is clearly not possible, how to handle situations like these?
0
What is the Unity 2019.3.5 version of UnityEngine.UI.Text ? I was following a tutorial on how to create a dialogue Box in Unity, and in one part of the tutorial the tutor imports UnityEngine.UI and creates an object of type Text, but my version of Unity is 2019.3.5f1 and I learned through searching a bit online that this UnityEngine.UI doesn't exist anymore in this version, and that it was replaced with UnityEngine.UIElements, and this Text type doesn't exist anymore as well. I couldn't find a replacement for Text or what is the new nomenclature, nothing from trying stuff that popped in the auto complete or searching for answers in the Internet gave me answers. Maybe I just searched poorly, but if anyone happens to know, could you kindly answer?
0
Subclasses in unity editor I would like to implement an action system where gameobjects offer different actions available to characters. Actions are composed of several steps holding the details to be performed. These steps have different logic applied to them (go to location, play animation for a time, change variables), so I would like to have them as subclasses. However I would also like to be able to set up the actual data for an action in the UnityEditor. I know it is possible to do this using ScriptableObjects, but that requires creating an asset for each instance of a step, which I'd like to avoid, since only the classes get reused, the instances being pretty much unique to each gameobject. Is there a way to work with subclasses in the unityeditor without requiring a dedicated asset for each of the subclass instances cluttering up my folders?
0
How to select multiple frames from a sprite sheet in unity I have a sprite sheet and cannot figure out how to select multiple frames in unity 5.5 I am watching a tutorial and it doesn't say how to do it. Is there a button I have to press while clicking or is it having to change some settings?
0
Unity ScrollRect many objects perfomance issue I have scrollrect setup and over 1000 objects to scroll through. Currently i'm Instantiating all the 1000 objects at once and notice fps drop. I'm using 2d mask and disbale pixel perfect. Both gave a perfomance boost, but i still Think the bottleneck is that i have 1000 objects already created on the scene. Instead create what is visible to the eye. What can i do? I've looked into pools. But i dont know how i should use it in my case. Since the inventory is dynamic. public void ShowInventory(PlayerObject player) for (int i 0 i lt inventory.GetContainerSize i ) Item item inventory.GetContainer i Button itemButton Instantiate(buttonPrefab, content) itemButton.GetComponent lt InventorySlot gt ().SetInventorySlot(player, item, item.amount)
0
Unity ECS How do I stop an entity from spawning twice? I am implementing a flight dynamics model using Unity's built in ECS package, Entities, and I keep running into one particular issue where the aircraft I'm trying to spawn gets converted into an entity twice. Essentially, I have a singleton Monobehaviour that handles setting up the aircraft entity from a GameObject Prefab. Here's the script public class GameManager MonoBehaviour private BlobAssetStore blobAssetStore public static GameManager main public GameObject planePrefab public float zBound 0.0f public float throttleMaxBound 1.0f public float alphaMaxBound 20.0f public float bankMaxBound 20.0f public float flapMaxBound 40.0f public float throttleMinBound 0.0f public float alphaMinBound 0.0f public float bankMinBound 20.0f public float flapMinBound 0.0f public State state public Properties prop Entity planeEntityPrefab EntityManager manager private void Awake() if (main ! null amp amp main ! this) Destroy(gameObject) return main this manager World.DefaultGameObjectInjectionWorld.EntityManager blobAssetStore new BlobAssetStore() GameObjectConversionSettings settings GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, blobAssetStore) planeEntityPrefab GameObjectConversionUtility.ConvertGameObjectHierarchy(planePrefab, settings) SpawnEntity() private void OnDestroy() blobAssetStore.Dispose() void SpawnEntity() Entity plane manager.Instantiate(planeEntityPrefab) prop new Properties( 16.2f, 10.9f, 2.0f, 0.0889f, slope of Cl alpha curve 0.178f, intercept of Cl alpha curve 0.1f, post stall slope of Cl alpha curve 3.2f, post stall intercept of Cl alpha curve 16.0f, alpha when Cl Clmax 0.034f, parasite drag coefficient 0.77f, induced drag efficiency coefficient 1114.0f, 119310.0f, 40.0f, revolutions per second 1.905f, 1.83f, propeller efficiency coefficient 1.32f propeller efficiency coefficient ) state new State( 0.0f, time 0.0f, ODE results 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, roll angle 4.0f, pitch angle 0.0f, throttle percentage 0.0f flap deflection ) float3 position new float3(state.q1, state.q3, state.q5) manager.SetComponentData(plane, new Translation Value position ) After a little bit of commenting here and there, I was able to determine that the following two lines are responsible for creating two separate entities, though the latter is the only one I'm capable of manipulating using the system. It's also worth mentioning that these two entities are virtually identical in the Entity Debugger, except for the fact that the first entity contains the quot prefab quot tag. planeEntityPrefab GameObjectConversionUtility.ConvertGameObjectHierarchy(planePrefab, settings) and... Entity plane manager.Instantiate(planeEntityPrefab) Is there a way to spawn this entity without both showing up in the debugger or is this unavoidable? If not, is there a way to remove the entity with the quot prefab quot tag from the world? Thanks! )
0
Endless 2d runner with increasing speed, how to adjust jump behavior? I am making an endless 2d runner with unity. my player object is not moving at all, i move all the other game objects. I have a SpeedManager script which increases the "speed" at every update by a short amount. The movement speed of every gameObject which is streaming towards the player is now multiplied with the SpeedManager "speed". One controll of my player is a jump. Currently i am using public Vector2 jumpForce new Vector2(0, 350) rigidbody2D.AddForce(jumpForce) The problem now is, as the game goes on, the game objects pass faster and faster but the player jump remains the same. What i want is a jump that goes as far as before, which means, the player should jump faster into the air, reach the same height and drop faster to the ground, so the jump distance is the same. I tried some stuff like multiplying both the jumpForce.y and the gravity of my player object with my SpeedManager.speed, but i did not achieve anything yet. ) Greetings.
0
Spawn skateboard under player I would like to know whys in which one can spawn skateboard under player like we see in subway surfers. My best two guesses are, 1.Spawnning skateboard and then making it child of player. 2.Changing current child prefab of player with skateboard attached prefab. With first approach ,its get complicated to know exact character's leg position. What you think is the best way? if you know any other good way then please mention . Thanks in advance
0
How do I use trigger colliders in Unity? I am trying to create a "Fruit Ninja" style game in Unity in VR. I have a BoxCollider on my sword set to "Trigger" and I have some "fruit" objects coming towards it. I then have this function void OnTriggerEnter(Collider other) Destroy(gameObject) Destroy(other.gameObject) I've tried applying this script to the sword and to the objects, but nothing is destroyed. In the documentation, there is also a note of "Trigger events are only sent if one of the Colliders also has a Rigidbody attached", but I've attached a Rigidbody to the objects.
0
Box2d on authoritative server for Unity client I'm creating a multiplayer platform and shooting game in unity, using unity2d's own physics system (box2d). But the truth is that I am quite lost in the creation of an authoritative server in c . I have quite clear and experience in the use of socket for communication between client and server, I do not know how to approach the issue of simulating the physics of my game on the server so that it decides the positions movements of the clients. Can anyone guide me to use box2d on the server, as I simulate the game on the server? Is this a good option or would it be better to implement my own game physics than to use the non deterministic engine? Thank you very much and sorry for my level of English
0
Move gameObject in its facing direction I have the following four gameObjects, they have, respectively, the rotations 90, 0, 90, 180. I want them to move as denoted in the image below This is what I got so far public class Projecttile MonoBehaviour public float speed private void Update() transform.Translate(transform.up speed Time.deltaTime) The result of my code is the following Why does my code result in this outcome, and how can I make each gameObject move in the direction it's facing?
0
Does 2D Platformer games still have popularity among gamers? I'm currently working on a 2D platformer game that i wanted to put out as my first game but seeing the popularity of other games made by Voodoo and others are quite distressing and made me ask myself this question and now you guys. will the 2D Platformer games that had the popularity will have any popularity for developers to take interest and make some living out of it in the for future projects or can they work on the more popular games like color bump 3d.
0
How do I tell if an object is currently colliding with another object? I can't figure out how to tell if a GameObject is currently colliding with another in Unity. I've looked online and can't find any tutorials or answers that work. Also, what's the difference between a Collision and a Collider w.r.t. Unity? My dilemma I have a third person controller set up and want it to wall jump. I already have an isGrounded function, I just need to test if I'm hitting anything other than the floor. Otherwise I want it to wall jump backwards. I've already tried if (this.OnCollisionEnter) ... if (Collider.OnCollisionEnter) ... But it did not work. I now tried function OnCollisionStay() Debug.Log("Collision") I checked my logs, console and still can't find anything.
0
Unity Matrix4x4 to rotate a point around a pivot axis I need the Matrix4x4 to rotate around a given axis that does not go through (0,0,0). Is there some built in straightforward way to do this in the Unity libraries, or do I need to build and maintain my own? Below is the formula I'd use to build my own in case somebody needs it We will define an arbitrary line by a point the line goes through and a direction vector. If the axis of rotation is given by two points P1 (a,b,c) and P2 (d,e,f), then a direction vector can be obtained by u,v,w d a,e b,f c . ... Assuming that u,v,w is a unit vector so that L 1, we obtain ... Source I do need the rotation Matrix, not just the rotation. If I didn't need the Matrix I could use (not tested, may contain flaws, but you get the idea) public Vector3 RotatePointAroundAxis(Vector3 point, Ray axis, float rotation) return Quaternion.AngleAxis(rotation,axis.direction) (point axis.origin) axis.origin So far the best I've got is the equivalent of the above (not tested, may contain flaws, but you get the idea), but it looks quite wasteful public Matrix4x4 RotationMatrixAroundAxis(Ray axis, float rotation) return Matrix4x4.TRS( Axis.origin, Quaternion.AngleAxis(rotation, Axis.direction), Vector3.one) Matrix4x4.TRS(Axis.origin, Quaternion.identity, Vector3.one)
0
What is the best way to code grinding for a skate game in Unity? I am making a inline skate game, what could be the best method to code the grinding system, there are many various and complex stuff to use but what could be used to set it up simple and not that complex? I made some research, I come up with Catmull Splines or Bezier curves but that seems very complex, my Idea is getting something simple to build up on that and improve it. Maybe use a simple waypoint system that the player follows along while jump on a trail or something. Any ideas or suggestions? Because you cant find any tutorials on grinding system in YouTube or somewhere. Thanks.
0
How can I serialize lists to JSON on mobile? I'm having difficulties serializing lists with the built in JsonUtility. I eventually figured out this just isn't possible with its limited capabilities. As much as I'd like to use Newtonsoft, I cannot use that either because this is a mobile game, and from what I understand it doesn't work on Android or iOS. Does anyone have any suggestions for how I can serialize my lists on mobile? I don't want to have to use hacky solutions to get these lists in and out of JSON.
0
How to stop all character movement when jumping against the side of a platform? My Sprite is Moving against a platform. I have a script and an unusual one (that's what one of the member said.) My isGrounded isn't using any rayCasting. I didn't have any problem with it but when I created a platform and jump against it My character would fall down slowly. If I try to move against the platform, I would be able to move and it would appear as if the character was flying. So question is, how can I stop all my movements, jumping everything, when I collide like this with a platform? My Code is using System.Collections using System.Collections.Generic using UnityEngine public class pScript MonoBehaviour public Rigidbody2D rb SerializeField public Transform Points SerializeField public float radius SerializeField public LayerMask layer public bool jump public bool isgrounded false SerializeField public float MoveSpeed SerializeField public float jumpHigh public bool facingRight public Animator animator public Object CallfPanel public Object CallfText public float Move 8f public Vector3 Dir public Vector3 tart Use this for initialization void Start () rb GetComponent lt Rigidbody2D gt () animator GetComponent lt Animator gt () CallfPanel GameObject.Find ("Panel") CallfText GameObject.Find ("Text") Update is called once per frame void Update () RaycastHit hit Debug.DrawRay (transform.position, Vector3.right, Color.white, Move) tart new Vector3 (200, 300, transform.position.z) Dir Vector3.right if (jump true) if (Physics.Raycast (tart, Dir, out hit, Move)) jump false float horizontal Input.GetAxis ("Horizontal") animator.SetFloat ("speed", Mathf.Abs (horizontal)) isgrounded isGrounded () rb.velocity new Vector2 (horizontal MoveSpeed, rb.velocity.y) if (Input.GetKeyDown (KeyCode.Space)) jump true if (isgrounded amp amp jump true) isgrounded false rb.velocity new Vector2 (0, jumpHigh) if (isgrounded false) jump false changeDirections () private bool isGrounded() if (rb.velocity.y lt 0) foreach (Transform points in Points) Collider2D collider Physics2D.OverlapCircleAll (points.position, radius, layer) for (int i 0 i lt collider.Length i ) if (collider i .gameObject ! gameObject) return true return false public void changeDirections() float horizontal Input.GetAxis("Horizontal") Vector3 theScale transform.localScale if (theScale.x 1) facingRight true else facingRight false if (horizontal gt 0 amp amp !facingRight horizontal lt 0 amp amp facingRight) theScale.x 1 transform.localScale theScale public void showTextDuration() float lifetime 4.0f Destroy (CallfPanel, lifetime)
0
How to transition a coin to the middle of the screen then up when collecting it? I have a coin sprite that animates spinning in place, like this. When the player picks up the coin, I want to make a transition while keeping the animation. First moving towards middle, then much faster all the way up until it leaves the screen like this My question Is this done mostly via adjusting the Transform component component via scripting? Or are games implementing something like this in a different way?
0
Unity Physics Trouble with Platform Objects Hi Game Development Community! I'm new to designing in unity, and I'm having some issues with my player game object traveling through platform game objects. Several of my game objects (pink in pictured) are successfully acting as a surface for the ball (purple). But others (cylinders in white) are not. The ball goes straight through them. Yet I'm not seeing a difference in the cylinder and cube's physics settings I've set. Any advice or solutions to this problem are much appreciated!
0
SetActive doesn't work for GameObject I'm using Unity 2D for my game and I'm facing a weird problem. I have a GameObject (an image) in my scene with a button attached to it. When the player is out of the screen, the image that works as a GameOver panel appears and in case of enough coins, you can resume the game. Everything works fine but when the image appears and I click on button to resume, the image doesn't disappear while the function for decreasing number of coins still works. Here is my script in which di() is for die and but() for button using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI using CodeStage.AntiCheat.ObscuredTypes using CodeStage.AntiCheat.Detectors public class UIManager2 MonoBehaviour public static ObscuredInt coin score 0 public Text coin text public Slider slider public Slider slider1 public Slider slider2 public GameObject bul public bool reverse public float timer public int delay 1 public float speed 0.5f public GameObject pause public AudioSource aud new AudioSource 3 void Start () coin score ObscuredPrefs.GetInt ("Score") StartCoroutine (elapsed ()) slider1.minValue 0 slider1.maxValue 20 bul GameObject.FindGameObjectWithTag ("Player").GetComponent lt Plane19 gt ().bullet void Update () timer Time.deltaTime if (timer gt delay amp amp reverse false) timer 0f slider2.value if (timer gt delay amp amp reverse true) timer 0f slider2.value speed coin text.text coin score.ToString () ObscuredPrefs.SetInt ("Score", coin score) if (slider2.value 10) bul.SetActive (false) reverse true if (slider2.value 0) bul.SetActive (true) reverse false public void di() pause.SetActive(true) GetComponent lt AudioSource gt ().Pause() Time.timeScale 0 aud 0 .Play() aud 1 .Pause() aud 2 .Pause() public void but() pause.SetActive(false) Time.timeScale 1 aud 0 .Pause() aud 1 .UnPause() aud 2 .UnPause() GetComponent lt AudioSource gt ().UnPause() UIManager2.coin score 2 IEnumerator elapsed () yield return new WaitForSeconds (2f) slider.value StartCoroutine (elapsed ())
0
Adding text to gameobject I'm trying to create a falling word game like z type (code here). I have created 3 game objects and I want the words to be added as text to these game objects something like a health bar is added to enemies etc. This is the word spawner script that spawns the word on screen. public GameObject wordPrefab public Transform wordCanvas public WordDisplay SpawnWord() Vector3 randomPosition new Vector3(Random.Range( 2.0f, 2.0f), 7.0f, 0) GameObject wordObj Instantiate(wordPrefab,randomPosition, Quaternion.identity, wordCanvas) WordDisplay wordDisplay wordObj.GetComponent lt WordDisplay gt () return wordDisplay Right now the words are spawned at a random x position and y position of 7.0. Instead of this how can I assign the words to the gameobjects that I have created. Edit I have created a spawner that spawns 3 enemies at the top of the screen and they start falling down to the bottom. Here is the script attached to the enemy game objects public float fallSpeed 1.0f public GameObject wordPrefab private Transform parent public WordDisplay SpawnWord() Vector3 randomPosition new Vector3(Random.Range( 2.0f, 2.0f), 7.0f, 0) GameObject wordObj Instantiate(wordPrefab, randomPosition, Quaternion.identity, parent) WordDisplay wordDisplay wordObj.GetComponent lt WordDisplay gt () return wordDisplay Update is called once per frame void Update () transform.Translate(0, fallSpeed Time.deltaTime, 0) I have also removed the SpawnWord() method from the wordspawner script. However the words don't spawn along with the enemy gameobjects. There is one more script called the WordTimer. Not sure where to add this code. This is from the original code that's on github. public WordManager wordManager public float delay 1.5f private float nextWord 0f void Update() if (Time.time gt nextWord) wordManager.AddWord() nextWord Time.time delay delay 0.95f
0
Why isn't my image's transparency honoured in the Unity sprite? I'm following through Jesse Freeman's Lynda course Unity 5 2D Essential Training. The exercise files contain sprites with transparency. Here's a screenshot of one such sprite on the trainers screen (sorry it's so small) But here's how it looks in my scene in Unity 5.5.0F3 I think that the sprite's alpha properties are set correctly, I have Alpha Source set to "Input Texture Alpha" and Alpha Is Transparency is checked When I open the PNG in PhotoShop the transparency is correctly set Why is the transparent area rendered as opaque in my sprite?
0
NGUI UIInput Reset value of password field How do I reset the value of a NGUI UIInput control that marked Is Password. If I set .text to "" I still see a bunch of rather than the .defaultText. Basically if the user types the wrong password during login, I want to clear the field and have is display the default text again. Update If I click into the field and back out, the default text shows, but until I do that I get the . Code Show the Create dialog public void ShowCreate() panelWait.gameObject.SetActive(false) panelLogin.gameObject.SetActive(false) panelCreate.gameObject.SetActive(true) username loginUsername.text createUsername.text username createPasswordA.text "" createPasswordB.text "" Image
0
Which collider to use on "island" situation? I have a 2d top down unity game where the player is on an island. The shape of the island is random generated and he is not able to "escape" from the island. So which Collider should I use for realizing this? Is there some form of an "inverted" collider? Are colliders able to have a hole in them? Or should I create a polygon collider with a small gap (This could be quite difficult if the polygon bends the wrong way)?
0
How can I my homing missile avoid walls (2D)? Okay, I have the homing missile implemented. It will follow the player, but I want it to avoid the walls. I tried out A but I want to make my own. I need some help plzz.
0
Get relative angle to collision Unity I want to get the angle between the rotation (euler Angles) of the camera (V1 Vector3) and the collision point of my character, when it hits a wall, to determin, if it was left, right, or in front of it.I tried to use Vector2.Angle with V1 and V2 (ControllerColliderHit.moveDirection as a Vector2) to get the difference between them. However I get a different value (0, 90, 180) when running into the wall depending on the world direction. (left wall, right wall, etc.) How can I get the angle of the collision point relative to the direction the camera is facing?
0
How to rotate a character according to the body alignment of the ragdoll to fit the 'getting up' animations? I'm trying to make a character rotate in the right direction so that when the character gets up from a ragdoll state, the animation would closely match the initial lay down position of the ragdoll. The character has a third person controller and when I move it around, it rotates according to the directions from the joystick. So when it falls it usually gets up in the right direction but sometimes, when the character falls from a cliff, the animation doesnt match the ragdoll orientation. I'm using this method to calculate whether the hips are pointing upward or downward so I can trigger the right animation. wasRootBoneFacingUpward Vector3.Dot(bones 0 .forward, Vector3.down) lt 0 How can I rotate my character so that it fits the body alignment of the ragdoll ?
0
Animation package from Assert Store not working probably with Unity Model Custom Model? I downloaded the animation pack from here https www.assetstore.unity3d.com en ! content 25794 The assert contains a fbx file, which contains a bunch of animations. Then in Animator window I added a State and transitions between states and have set the Motion in the inspector of the state. Then I look at the preview in Animator's inspector with it original Model, the animation works properly If I apply Unity Model or my custom Model in the preview, its became Why is that? How can I fix it? Or did I use it incorrectly?
0
Unity animation tool doesn't save changes I'm trying to create an animation inside Unity using the animator tool, however the record tool isn't recording my changes and I'm struggling to get this to create animations. I have created an example here https i.gyazo.com 91f88b3531b4fb3ffd4100d40f06bdcf.mp4 I have tried recreating the animation file, but no matter what I do it refuses to record the element? Any information would be appreciated, as it appears unity may be bugged. When applying an update between tweened keypoints the fields for X Y Z are red and do not apply changes
0
Unity UI Mask is not working in samsung SM G610f I am using unity 2018.3.13f1 and getting the issue that unity ui mask is not working in a specific device like Samsung SM G610f. The masking work in other android devices. But(Samsung SM G610f) the mask became rectangle. Below is the reference image link. https drive.google.com file d 1aTvKIxFh0HhNXgTYg5FOqvTsCy0aqr4e view?usp sharing Please help. Thanks.
0
Block player movement What do i need to keep my player model from going through environment objects like walls, trees etc? Im trying to figure out if should use rigid bodies and the built in physics but i feel that its too difficult to predict what will happen then. Is there an alternative that still will prevent the player from going through environment objects? At the moment my player is a 3d model compsosed of some primitive shapes and a capsule collider.
0
Unity Transform Origin during Animation I have a sliding animation on this penguin model which moves the penguin from a standing position to a belly position. During this animation, I've noticed that the object transform origin stays locked relative to the animation, using the encoded origin from blender. In my case this is an undesired pivot point and is often buried beneath other game objects I may want to raycast against. Ideally, I am hoping to have the origin centered in the model with respect to the XZ plane throughout the animation. Toggling the handle position tool to quot Center quot in the editor gives me an origin that is closer to what I would like, however I understand this is just a feature of the editor and does not reflect the true object transform. My question for everyone is What are some ways I can achieve a transform that follows the body of my animation? I have parenting an empty game object, but this transform still would not follow the body animation. For raycasting below the body specifically, I am considering following the transform of my armature's spine which does follow the animation. Would this be a valid approach? Any help is much appreciated!
0
Only StartCoroutine of Update on child prefab functions I have a script attached to a prefab. That prefab attached to a child and I want it to rotate the root transform. The Update of the script executes nothing but the Coroutine of a class I wrote. Attached is the hierarchy of the outside and inside of playmode as well as the script on the prefab and the class. From the Editor, Not on Playmode. and in Plamode uiTurnTileScropt.cs THIS SCRIPT IS CURRENTLY ON THE CCW PREFAB using UnityEngine using System.Collections public class uiTurnTileScript MonoBehaviour public float rotSpeed 7.0f public float degree 36.0f public float waitTime .3f private bool rotate false private Quaternion newRotation Quaternion.identity BlockButton clickTapBlocked void Start() clickTapBlocked gameObject.AddComponent lt BlockButton gt () clickTapBlocked.bttnName "clickTap" clickTapBlocked.setFalse() void Update () Debug.Log (transform.name) if(Input.GetButtonDown (clickTapBlocked.bttnName) amp amp (!clickTapBlocked.blocked) ) Debug.Log("MouseDown") StartCoroutine(clickTapBlocked.forTime(waitTime)) newRotation Quaternion.AngleAxis (transform.root.rotation.eulerAngles.z degree, Vector3.forward) rotate true RotateSetAmount () void RotateSetAmount() Debug.Log ("In Rotate function") if (rotate) this.transform.rotation Quaternion.Lerp(transform.root.rotation, newRotation, Time.deltaTime rotSpeed) if (transform.root.rotation.eulerAngles.z lt newRotation.eulerAngles.z) transform.root.rotation newRotation rotate false and the referenced class BlockButton in uiTurnTileScript.cs using UnityEngine using System.Collections This class is more intuitive if you name thie instance created ("buttonValue" blocked) Example for a button in the Input Project settings with a string of Fire1 I would name the instance fire1Blocked Declare with your other variables BlockButton fire1Blocked void Start() Fire1Blocked gameObject.AddComponent lt BlockButton gt () Fire1Blocked.bttnName "Fire1Blocked" Fire1Blocked.setFalse() public class BlockButton MonoBehaviour public string bttnName public bool blocked false public bool setFalse() blocked false return blocked public bool setTrue() blocked true return blocked public IEnumerator forTime(float duration) Debug.Log ("I was called") float dur duration blocked true yield return new WaitForSeconds(dur) blocked false In my output,no matter what I click, I get nothing but the code from the BlockButton Instance. No debug from the Update() happens but the coroutine happens. I am not understanding how that happens and how to implement this properly. Any help is appreciated.
0
Art style for a character that has frequent visual changes during gameplay I'm creating a game with a bodybuilding fitness theme. The camera will almost always be focused on an inclined front view of a character who will be evolving very frequently during the game as the player 'levels up' the musculature of each part of the character such as arms, legs, chest, etc. I've been doing some research trying to figure out the most economical yet effective way to incorporate this visual mechanic of letting individual parts of a character independently increase in size and detail and have come up somewhat short, most likely due to my complete lack of experience when it comes to art (my experience is mostly in programming). I was thinking 2D would be best for this game, however maybe this one character should be in 3D? Would a low poly style fit these requirements, or should I look towards something akin to sprites or hand drawings? The games interactivity will be purely through menus so that doesn't need to be taken into account when dealing with the problem of this character. I would like this character to have some animations, of course, however I'm not sure if that fits the scope of this single question.
0
Make an object rotates by an arbitrary angle and rotates toward a target in Unity I have an object facing up in Unity. I need it to move from point A to point B, without prior knowledge of where A and B are. So when I place it at point A, I need to rotate it toward point B. I used this this.gameObject.transform.rotation Quaternion.FromToRotation(A.position, B.position) However, before doing the movement, I also need to rotate the object by 90 around the X axis. I used this this.gameObject.transform.rotation Quaternion.Euler(90.0f, 0.0f, 0.0f) These two functions worked, but separately. When I try to use these two functions together, the last function called overrides the other.
0
How to stop an animation from looping I want to make Unity play a squish animation when the player hits the ground, but only once, until the player jumps and hits the ground again, although Unity its constantly detecting that the player is on the ground and keeps playing the squish animation over and over again, only jumping stops it cause the condition to play the animation is if the player is on the ground. (loop already disabled) How I can possibly solve this? if (isGrounded true) anim.SetTrigger("EnterGround")
0
Advance efficient water physics simulation Summary I am looking at creating a large(ish) ocean which multiple ships will be present in doing their own thing. I want the ocean to be a life like as possible but without compromising too much on rendering speeds. A Little more detail I am using Unity to create the game in and ultimately I will need to be able to release the game as a web player to there lies my limitations of the water simulation. For the actual simulation of the ocean I will need it to be able to react to the ships movement and vice versa. The end product of the simulation I want to be able to look like this simulation of a ship in water (if possible) to be done efficiently. http youtu.be H4ACKAUU3O0?t 3m51s I have started reading up on other information and looked at the other similar questions to mine 1) Water Ocean simulation and physics I have read this question fully, am looking at not using wind as said in this question but will use this as a reference when creating the final product. (I would like to add to the information from that question with the answers on this question.) 2) Resources of realistic water simulation? I have started going through the tutorials that the answer linked to and so far they seem good but do not look like they will answer my question. The water will have splashes in reaction to the objects in the water (particle effects I believe) and small waves will come off the objects in the water e.g. ripples. Also if you are a smart cookie that wants to be awesome you should include in your answer about putting a shader on the water. Also since the ships will be moving all at independent speeds and traveling through the sea, for efficiency I don't want to just make the water massive so is there a way to only render simulate the water within a certain radius from each of the ships? What I am looking for in an answer I would like to know the what tricks for making this type of simulation light weight can be used for these types of water simulations and specifically in unity. What limitations will I encounter when creating this and why they are limitations The basic work flow of creating something like this step by step. (e.g. step 1 to make the object that will be in the water) Are there any open source projects for these types of simulations?
0
When using IK the player head is looking at down the ground instead looking at the object target up what can be the problem? This script is attached to the player using UnityEngine using System using System.Collections RequireComponent(typeof(Animator)) public class CharController MonoBehaviour protected Animator animator public bool ikActive false public Transform lookObj null public float lookWeight 2f void Start() animator GetComponent lt Animator gt () a callback for calculating IK void OnAnimatorIK() if (animator) if the IK is active, set the position and rotation directly to the goal. if (ikActive) Set the look target position, if one has been assigned if (lookObj ! null) animator.SetLookAtWeight(lookWeight) animator.SetLookAtPosition(lookObj.position) if the IK is not active, set the position and rotation of the hand and head back to the original position else animator.SetLookAtWeight(0) When the lookObj is a sphere or a cube it's working fine but if the lookObj for example is a big spacecraft now the player head will look to the ground down and not to the spacecraft up The problem is that the center of the spacecraft is at the bottom this is a screenshot when it's showing the spacecraft at regular when it's in Pivot mode Now when I click on the Center button now the center of the object is at the bottom Is there any way to fix it maybe eve fix it ?
0
My 2D Sprite Diffuse material is not lighting when I start the game I put a Sprite Diffuse Material on my Player. In the scene, before starting the game it looks ok (1st screenshot). After starting the game it still works fine, but when I am starting to move the player on x axis the it becomes black (2nd screenshot). Why? This is the script I use to transform the Player's position and scale void Update() Move() float moving Input.GetAxis("Horizontal") characterAnim.SetFloat("Speed", moving) void Move() if (Input.GetKey("right")) transform.localScale new Vector2(1, 1) transform.Translate(Vector2.right speed Time.deltaTime) if (Input.GetKey("left")) transform.localScale new Vector2( 1, 1) transform.Translate(Vector2.right speed Time.deltaTime) rb2D.AddForce(transform.up 20)
0
Activate and Deactivate Mouse Cursor on UI I have a player with a character controller component. When the player is generally interacting with the UI I would like to stop the character and camera controller and show the cursor to the player in order to (e.g select a weapon) and when they're done I would like it to switch back. How do I address this issue?
0
The underlying mechanism in 'yield return www' of Unity3D Game Engine In the Unity3D game engine, a common code sequence for getting remote data is this WWW www new WWW("http remote.com data location with texture.png") yield return www What is the underlying mechanism here? I know we use the yield mechanism in order to allow the next frame to be processed, while the download is being completed. But what is going on under the hood when we do the yield return www ? What method is being called (if any, on the WWW class)? Is Unity using threads? Is the "upper" Unity layer getting hold of www instance and doing something? EDIT This question is specifically about Unity3D internals. I'm not interested in explanations of how yield statement works in C . Instead, I'm looking for an inside view of how Unity deals with these constructions, to allow, for example, to WWW to download a piece of data in a distributed manner across several frames.
0
How to build a game for linux in unity I made a game and uploaded it to a game site. I exported the build as windows mac OS and Linux. My thinking was that it supported all of those platforms but i guess not. Someone commented saying that the game didn't support linux. I have no idea why since it said it built for mac and windows and linux. Do i have to change settings? If so were? if its target platform i cant because the only option is windows.
0
I can't drag'n'drop UI Elements from the Scene hierarchy into a public field (Unity 5) I just watched this Video https unity3d.com learn tutorials projects survival shooter player health and tried to drag'n'drop the UI Elements on the matching script, just like they did. But this is not working for me. If I hover the public field Unity shows up an error icon and I can't drop it there. If I set this UI Element as prefab I can place it there, but it does not update the Element which is in the Scene when the Code is live. The Elements just gets an update after each restart. Can anybody explain to me why I cannot drag'n'drop my Object from the hierarchy to the public field?
0
Occasional lag spikes in performance in heavily optimized game (profiler screenshots included) So I've been working on a mobile based platformer for a few years now. I've spent more than a year optimizing the game for mobile as much as I could. Almost every single one of my meshes are using Mobile Diffuse shader. When I test the performance of my game (on my phone) with the profiler, the frame rate stays at clean 60 fps for the most part. The CPU time fluctuates between 16 ms and 17 ms. The rendering statistics are also excellent, with draw calls fluctuating between 18 and 25, triangles fluctuating between 1.0k and 2.0k and vertices fluctuating between 2.0k and 3.1k. Below is a screenshot of the Rendering profiler when the game is running smoothly. I believe that for a mobile device, these should be very good numbers. However, every now and then, I see a spike in the profiler window (see below) According to the profiler, the spike is being caused by Render.OpaqueGeometry. Under normal scenarios (when the performance is smooth), Render.OpaqueGeometry takes between 1 ms and 2 ms of CPU time. However, as you can see in the screenshot above, Render.OpaqueGeometry is taking 5.36 ms of CPU time and the total CPU time has jumped to 24.16 ms. Based on my observations, this spike shows up once or twice per minute. Sometimes, several minutes go by without any spikes. And in very rare occasions, the spike can show up 3 times in a single minute (although I don't think that happened the last couple of times I tested it). So why do you guys think this is happening despite the game being heavily optimized? I read in a post in Unity Answers that Render.OpaqueGeometry spikes are frequent in all games and it's nothing to worry about. But do you think 2 spikes per minute is too frequent for a simple platformer?
0
Unity camera moving up and down for no reason I have a standard camera in my scene. With standard I mean the camera you get when you click right mouse Camera, with no modification except for the transform position and rotation. Then I attached to the camera this simple script using System.Collections using System.Collections.Generic using UnityEngine public class CameraController MonoBehaviour public GameObject target public Vector3 translationOffset public Vector3 rotationOffset Use this for initialization void Start () Update is called once per frame void Update () transform.position target.transform.position translationOffset transform.LookAt(target.transform) transform.Rotate( rotationOffset) the result I have is this Why my camera is doing that? It may be worth noticing that everything was working fine, but at some point i clicked on "reimport all assets" and it started this weird behaviour. How can I fix? Thanks a lot.
0
Render texture seems to ignore camera background type I'm currently trying to pull a fog of war for an rts game, and planned it like this. (Unity 2020.2.7, URP 10.3.1) Use units field of view to generate a texture of what is seen (alpha 0). Create other render texture to generate fog (alpha gt 0 amp amp alpha lt 1) by not clearing camera buffer. Use the mask made between the two textures to cut the fog of war (alpha 1). Now i'm currently stuck at the 2nd step. Please check the image As you can see, the camera is doing what I want, but the render texture somehow clears the buffer, which just gives me the quot Use units field of view to generate a texture of what is seen (alpha 0). quot part again. This whole buffer thing has been hard to understand, i'm not sure if this implementation is right or not. I would be really thankful for any pointers given! D Cheers guys!
0
How can I get a Box Collider's "corners" (vertices) positions? I attached a Box Collider to a object, which has not the center as its pivot. Now I need the 8 corner points. Right now I can only get the points in a unrotated state. But whenever I rotate the Object (which rotates in the center of the boxCollider) everything gets messed up, because the rotation alters the gameObject Position. EDIT2 Solution public Vector3 GetColliderVertexPositions (GameObject obj) BoxCollider b obj.GetComponent lt BoxCollider gt () retrieves the Box Collider of the GameObject called obj Vector3 vertices new Vector3 8 vertices 0 obj.transform.TransformPoint(b.center new Vector3( b.size.x, b.size.y, b.size.z) 0.5f) vertices 1 obj.transform.TransformPoint(b.center new Vector3(b.size.x, b.size.y, b.size.z) 0.5f) vertices 2 obj.transform.TransformPoint(b.center new Vector3(b.size.x, b.size.y, b.size.z) 0.5f) vertices 3 obj.transform.TransformPoint(b.center new Vector3( b.size.x, b.size.y, b.size.z) 0.5f) vertices 4 obj.transform.TransformPoint(b.center new Vector3( b.size.x, b.size.y, b.size.z) 0.5f) vertices 5 obj.transform.TransformPoint(b.center new Vector3(b.size.x, b.size.y, b.size.z) 0.5f) vertices 6 obj.transform.TransformPoint(b.center new Vector3(b.size.x, b.size.y, b.size.z) 0.5f) vertices 7 obj.transform.TransformPoint(b.center new Vector3( b.size.x, b.size.y, b.size.z) 0.5f) return vertices Found that Most efficient way to get the world position of the 8 vertexes of a Box Collider (C )
0
what is the math behind the parenting a transform in unity? in unity when you parent an object or transform with another object, all transform(position, rotation, scale) are calculated depending on that parent object. sometimes we need to know about the local data of that transform and sometimes we need to know that data based on the world axis. I need to know how that is implemented in math and vector functions.
0
Pushing Rigidbody forward doesn't go straight I have a object that pushing rigidbody forward when it's instantiated GameObject grenade Instantiate(projectilePrefab, shootPoint.position, shootPoint.rotation) grenade.GetComponent lt Rigidbody gt ().velocity transform.forward.normalized 50 It seems fine, but when I ran the game, projectile always not going straight and it's little bit moving left or right. So I thought that shoot point wasn't pointing the right direction or my crosshair didn't centered properly, but unfortunately there were nothing wrong with them. I think there's no extra forces that affects physics in my scene except gravity, and gravity has default settings which only affects downside. But why projectile doesn't go straight and move little bit left? What am I missing?
0
Unity using 40 GPU for just a UI interface on ultra but 90 on low? So I made some software using unity for my FRC team. All this application is, is just a User Interface with labels, input fields, buttons, etc... When I choose the quality to be on Ultra, I will get about 50 GPU usage but when on very low, I got 90 , close to 100 . How can I optimize my software to use much less of the GPU(Preferably less than 15 )? I am measuring with the Task Manager Performance Menu
0
How can I scale a color component by Time.deltaTime and still fit it into a byte? I am confused about this issue, and I can't find why I get this and how to fix it properly from the Google searches I've tried. This is a short version of my code byte redtarget 70 byte greentarget 222 byte bluetarget 255 byte opacitytarget 1 byte redcurrent 0 byte greencurrent 0 byte bluecurrent 0 void OnMouseOver() redcurrent redcurrent redtarget Time.deltaTime greencurrent greencurrent greentarget Time.deltaTime bluecurrent bluecurrent bluetarget Time.deltaTime if(redcurrent gt redtarget) redcurrent redtarget if(greencurrent gt greentarget) greencurrent greentarget if(bluecurrent gt bluetarget) bluecurrent bluetarget theobject.GetComponent lt Renderer gt ().material.SetColor(" EmissionColor",new Color32(redcurrent,greencurrent,bluecurrent,opacitytarget)) Please ignore the other errors that could have been introduced when I copy pasted it to here. And this is the error I get As you see the error, "cannot implicit convert type float to byte", the problem is caused by Time.deltaTime that returns a float value, and I need a byte due to Color32. Is there any way to turn Time.deltaTime to byte? Or should I use another type of color that use floating point numbers? I'm a beginner with Unity so I'm sorry if this has already been asked somewhere as I said, I can't find it on the Internet.
0
Loading scene doesn't reactivate gameobjects I have some levels and a main menu. When starting the game from the main menu (in the editor debug mode) I can select a level a load it, no problem. However, when I wish to go back to the main menu using SceneManager.LoadScene(index) A whole lot of my gameobjects throw exceptions like The gameobjects is destroyed, but you are trying to access it and Missing reference exception and so on. However, when i start the level from the editor (and not using the main menu), I can go back to the main menu, it works as it should. NOTE that I don't have any persistent gameobjects. I do have singletons, but no persistence here. Any ideas what could cause the issue?
0
Unity3d Android Fixed Resolution How can i set a fixed 720p resolution on any devices using unity3d android? unity3d version 2018.4.5f1
0
Picking up items and references Just a heads up, I'm sure there are much more efficient ways to do what I'm trying to do. I've even thought of some myself. However, at the moment, I'm mostly interested in getting this code to work. I think I understand exactly why it doesn't work, but I'm not sure how to fix it. Firstly, there is an ItemPickupTrigger script attached to the drop prefab. The purpose of this script is simply to modify a variable's truth value depending on whether or not the player is in range. This script must be attached to the drop prefab because it uses OnTriggerEnter OnTriggerExit. No problem here. Secondly, there is a pretty standard EnemyDrops script. public class EnemyDrops MonoBehaviour private EnemyHealth enemyHealth public GameObject dropPrefab private float randomNumber public bool objectDropped private bool numberGenerated public GameObject drop This is the correct offset for enemies' current y position of 1.083333 private Vector3 dropPositionOffset new Vector3(0f, 0.958333f, 0f) void Start() enemyHealth GetComponent lt EnemyHealth gt () void Update() if (enemyHealth.isDead amp amp !objectDropped amp amp !numberGenerated) randomNumber Random.value numberGenerated true if (randomNumber lt 1.0) DropObject() private void DropObject() objectDropped true drop GameObject.Instantiate(dropPrefab, transform.position dropPositionOffset, Quaternion.identity) It drops the object where the enemy has been killed. This script is attached to each enemy. As it's currently set up for testing purposes, an item will always drop. I'm sure there are better ways to do this, but it works, so no problem here. Finally, there is an ItemPickup script attached to an ItemController object which is otherwise pretty empty. I'm not even really sure why I decided to do it this way, I just thought that it might be better for things I wanted to do in the foreseeable future to not have this script attached to each enemy. Now get ready because the code below is problematic. public class ItemPickup MonoBehaviour private GameObject pickupWindow private bool windowOpen private GameObject drop private ItemPickupTrigger itemPickupTrigger void Start() pickupWindow GameObject.Find("Pickup Window") pickupWindow.SetActive(false) drop GameObject.Find("Drop") itemPickupTrigger drop.GetComponent lt ItemPickupTrigger gt () void Update() if (Input.GetKeyDown(KeyCode.R) amp amp itemPickupTrigger.playerInRange amp amp !windowOpen) pickupWindow.SetActive(true) windowOpen true else if (Input.GetKeyDown(KeyCode.R) amp amp windowOpen) pickupWindow.SetActive(false) windowOpen false For starters, it only works if there is a drop object already present when the script begins, but there shouldn't be a drop object then. Second, if I don't set the reference there, I'm not sure how to set itemPickupTrigger's reference, since I'm using it in update and need the reference set before then. Make a function called SetReferences() and call it early in Update()? Yeah, I'm pretty lost. Basically, I want to be able to open the "loot window" near any instantiated drop object in the game. Currently, that functionality only in a limited capacity (either only on a "preexisting" drop object in the scene or on one random instantiated drop object(?) depending on how I have been modifying the code). Help!
0
Merging box colliders for optimization Look at the picture. The figure on the left shows the individual box colliders in green. The yellow boxes on the right are the results of the optimization of the original box colliders. What is the algorithm that makes this possible?
0
LookAt only in Z axis I'm fairly new to game development, like many of us asking questions here Currently, I'm trying my luck working on a simple space shooter. I'm trying to add some enemy ships with movement, they will only move forwards, but, at all time, will be facing the player ship I have that figured out, after playing with many options, LookAt was my saviour, but now, I'm having an issue, they do rate to face the player, but they also rotate on the Y axis This is how they are in the editor looking This is the position setting Their properties Their code using UnityEngine public class AlienMovement MonoBehaviour public GameObject PlayerShip public float speed Use this for initialization void Start () GetComponent lt Rigidbody gt ().velocity transform.up speed 1 Update is called once per frame void Update () transform.LookAt (PlayerShip.transform, Vector3.up) And how they look once the game is running (frame still) Transform properties for the one on the right Any idea what I'm doing wrong?
0
Unity Rigidbody gets pushed through collider by another rigidbody? I'm setting up the interior of a house in a 2D platformer. Inside the house is an NPC with a box collider and rigidbody attached, and the house is boxed in by four edge colliders. My character also has a collider and rigidbody. My NPC walks back and forth randomly, but when he pushes my character into the wall, the force of the push takes priority over the house's edge collider and my character gets pushed outside. Is there any way to give priority to the house's collider somehow, without removing the NPC's rigidbody?
0
Unity 5.6 Where have Sun Shafts disappeared to? I've just upgraded to Unity 5.6 from 5.4. I need to add some Sun Shafts to my camera but I cannot find the script anywhere. I've looked in the docs, I've looked in the menu's but I can't locate them. Has anyone else had this problem at all?
0
How can I get width and height of grouped objects in Unity3D Is it possible to get height and width of grouped objects like this? I tried boxcollider2d.bounds and renderer.bounds. Each shapes in the group has collider component. Is it possible?
0
How can I simple use global or individual bool flag s? using System.Collections using System.Collections.Generic using UnityEngine public class DoorsManager MonoBehaviour public bool globalDoorsLockState false public bool doorsLockState public GameObject doorsShieldFX Start is called before the first frame update void Start() doorsShieldFX GameObject.FindGameObjectsWithTag("ShieldFX") doorsLockState new bool doorsShieldFX.Length Update is called once per frame void Update() for (int i 0 i lt doorsLockState.Length i ) if (globalDoorsLockState true) doorsLockState i true else doorsLockState i false I want to be able to change all the doors flags to true false or each door individually. Now in the Update it's working only for the global. How can I add code or change it so it will also be able to change each door lock state individually?
0
ForceMode in AddTorque in Unity game development In UNITY game development platform while programming in C I came across a method to add torque to component public void AddTorque(float x, float y, float z, ForceMode mode ForceMode.Force) In this Function what is meant by ForceMode?
0
Lowering Unity launcher graphic quality settings reduces mouse x turn speed, does quality affect time? Lowering Unity App quality settings reduces mouse x turn speed, how to fix this? I am not sure why this happens my only thought was time.timedelta is affected by the graphics quality setting in unity launcher. when rotating a cube with input mouse x, the cube rotates at normal speed on high quality graphic settings, but lowering the graphic settings it begins to slow down. Inevitably at lowest it barely rotates. using UnityEngine public class This MonoBehaviour private float mouseTurn private float turnSpeed 64f void Update() mouseTurn Input.GetAxis("Mouse X") transform.Rotate(0, mouseTurn turnSpeed Time.deltaTime, 0)
0
How can I reflect a point about a line in Unity? I am drawing a line using the line renderer in the following way public class MyLineRenderer MonoBehaviour LineRenderer lineRenderer public Vector3 p0, p1 Use this for initialization void Start () lineRenderer gameObject.GetComponent lt LineRenderer gt () lineRenderer.positionCount 2 lineRenderer.SetPosition(0, p0) lineRenderer.SetPosition(1, p1) From the image below, the line P0P1 is known and so is point A. How can a point B, which is the reflection of A about the line P0P1 be found?
0
KeyCode dictionary in Unity I found a strange problem while programming keyboard input in Unity (v5.3.5). public class AvatarInputMapperUnityContext MonoBehaviour private AvatarController avatarController public KeyCode JumpKey KeyCode.Space public KeyCode LeftKey KeyCode.A public KeyCode RightKey KeyCode.D public KeyCode UpKey KeyCode.W public KeyCode DownKey KeyCode.S private Dictionary lt KeyCode, WeaponTags gt ShotKeys void Awake () avatarController GetComponent lt AvatarController gt () ShotKeys.Add(KeyCode.I, WeaponTags.Pistol) ShotKeys.Add(KeyCode.O, WeaponTags.Shotgun) void Update () if (Input.GetKeyDown(JumpKey)) avatarController.JumpSignal() Now, when the ShotKeys.Add... lines are commented out everything works fine. But when I uncomment them, the program never reaches the avatarController.JumpSignal() line, and none of the other directional keys (w,a,s,d) work. What can be the reason?
0
Rope 2D Hinge disconnection I have a game that needs to use a rope like mechanic should do two things. Restrict Player's Movement within the length of the rope. In other words, some kind of rubber band that brings the player back to the rope imitating real world. Rope sections should not go beyond their hinge limits I'm using the Rigidbody2D.velocity to move the player, the hinges do not stop the player from moving beyond the rope's limits. Thus, causing this visually breaking of the joints. This is more visible when we flip the player's scale x to 1 since we're moving the player to the left. This also causes the rope segments to spasm or rotate at absurd speeds. The break force is set to Infinity. I tried looking online for a solution but I'm not entirely sure what joint to use. These are my hinge settings Questions How do I fix the rope segments to not have these gaps? How do I safely flip the player without causing problems in the rope?
0
How can I reset the mouse axes when respawning a player? I am making a simple parkour game in which the camera will follow the mouse based on the mouse input axis the sensitivity. This works great, but when I want to reset my character to the start I cant figure out how to reset the mouse axis to zero, thus preventing me from resetting the camera rotation. I have tried Input.ResetInputAxes() , but that seems to only reset the buttons. using System.Collections using System using System.Collections.Generic using UnityEngine public class Movement MonoBehaviour public CharacterController characterController public Transform Player, camera public Camera cam public float XSensitivity, YSensitivity public bool grounded, jumping public float forwardSpeed, horizontalSpeed, jumpPower, gravity, sprintModifier HideInInspector public float sideSpeed, lastPlayerPosX, lastPlayerPosZ, jumpSpeed, verticalRotation, horizontalRotation private float isSprinting 1 void Update() This is where I get the axes float mouseX Input.GetAxis( quot Mouse X quot ), mouseY Input.GetAxis( quot Mouse Y quot ) This is how I rotate the player and camera verticalRotation mouseY YSensitivity Player.transform.localRotation Quaternion.Euler(0, horizontalRotation, 0) horizontalRotation mouseX XSensitivity cam.transform.localRotation Quaternion.Euler(verticalRotation, horizontalRotation, 0) if (Input.GetMouseButtonDown(0)) Cursor.lockState CursorLockMode.Locked float horizontal Input.GetAxis( quot Horizontal quot ), forward Input.GetAxis( quot Vertical quot ) grounded characterController.isGrounded if (grounded) if (Input.GetKey( quot left shift quot )) isSprinting sprintModifier if (Input.GetKey( quot left shift quot ) false) isSprinting 1f jumping false jumpSpeed 0 sideSpeed .75f else jumpSpeed (gravity 25) Time.deltaTime if (Input.GetKey( quot space quot )) sideSpeed .25f if (Input.GetAxisRaw( quot Jump quot ) ! 0 amp amp !jumping) jumping true jumpSpeed jumpPower lastPlayerPosX Player.transform.position.x lastPlayerPosZ Player.transform.position.z Vector3 motion new Vector3(horizontal horizontalSpeed sideSpeed, jumpSpeed, forward forwardSpeed isSprinting) characterController.Move((Player.transform.rotation motion) Time.deltaTime) void OnTriggerEnter(Collider col) if (col.gameObject.name quot deathbarrier quot ) Resets player to starting position Player.transform.position new Vector3(20.5f, 2, 22.5f) Is supposed to reset all inputs (including mouse) Input.ResetInputAxes() Sets camera rotation to 0, but only for one frame before the stored mouse axes change it camera.transform.rotation Quaternion.Euler(0, 0, 0) Thanks for any tips!
0
Disable system sounds in Unity? I've got an editor script in Unity 5 that uses the cursor position in the scene view to change objects in the scene when you press the space key. This all works perfectly, except that Unity thinks that space isn't a valid key to press, so it makes the system "boop" sound to let you know that it's invalid or that nothing happened. So, focus is on scene view, I press space, my script triggers, and the mac system "boop" sound activates. It spams the sound if you hold it down. Is there a way to Disable the system boops in Unity or Add space to registered hotkeys stop unity from triggering the system sound for a specific key (just to be clear, the script works, I'm just wondering about disabling the sound)
0
8 ball pool scratch card effect logic how to replicate this type of scratch card effect in Unity3D considering its for mobile. https youtu.be 6wLWu1BefXs Two cases 1. Clear part of screen where user touches. 2. How to trigger rewards after certain amount of image get reveal?
0
When importing a character to Unity, textures and meshes don't appear I'm relatively new to Unity, and I'm left with doing this as my last step towards my task importing my animated character to a game engine and program the movements. The problems that I have noticed are the missing textures and meshes, you can see in the first picture how it should look like in Blender, and what results I get in Unity The apple here doesn't have any holes, I think only one material got imported, and it doesn't look right. Textures are missing, the leaf near the stem is completely filled with gray texture. At least the animations work perfectly... Download link to my .blend file https pasteall.org blend 6c14ec0d9446404b81251585f83f3551