_id
int64
0
49
text
stringlengths
71
4.19k
0
Find the coordinates between two points based on third You can see two points in this picture. Points are surrounded by collider which is set to trigger. Points can either be Vector3 or Vector2, shouldn't make any difference. I need to get the coords on gray line if mouse enters the trigger, at the exact point where mouse and gray line form 90 degree angle. Gray line is just an straight line between 2 points. All the data left point coords right point coords mouse coords Is it possible with the data I have and how?
0
How can i save field member value of Scriptable Object when it changed on inspector at runtime? Class Foo(monobehavior) has a scriptableObject and it is exposed to Inspector. When i change its value on inspector on runtime, it is saved. but when i try to change its value by script on runtime, it is never saved. what the different? and is there a way to save changed value of scriptableObject on runtime? without using json.. or something. Thanks and sorry for my bad english.
0
Should I scale gravity for small objects? If I am working with objects that are small in real life, but in the Unity world they are scaled larger, should I increase the Gravity with the scale of the objects? For example, if an object of size one would actually be 10 cm across, would gravity scaled to be 10x make the object behave more like a small object would in real life. I know objects fall at the same rate, but the rate is the same so small objects fall more in proportion to their size don't they?
0
Algorithm to fill a shape defined by 4 pixel points? I'm developing an application in Unity3D where a user can define 4 pixel points on screen, and what I would like to do is fill this shape with pixels using Unity's SetPixel. While I can do this easily for square or rectangular shapes, I was wondering if there is any efficient code or algorithm to do this for more irregular four sided shapes, such as trapezoids etc. Note Filling the shape with a mesh is not an option. So far the best option I can think of is to draw the outline, then draw a line from each pixel point of every outline, to every other outline point, but I'm not sure that's very efficient.
0
2.5D platformer how to darken building edges? I was wondering how I could go about creating a vignette type effect some sort of volumetric shadow for the 'cross section' parts of a 2.5D level. The effect I'm going for can be seen in 'This war of mine' where the edges of the rooms and walls floors that are facing the camera have been darkened and blurred. (see below). I thought about creating the edges in photoshop and then blurring them and putting them in, however the blur scales weirdly as I'm re scaling the sprites so it looks really fake and not like a visual effect. Is there perhaps a 2d shader I could use or make? Any help on this would be appreciated! Cheers My photoshop attempt to recreate
0
How to change transform.position code to Rigidbody.AddForce? Vector2 vec new Vector2(horizontal, vertical) vec Vector2.ClampMagnitude(vec, 1) Vector3 camF cam.transform.forward Vector3 camR cam.transform.right camF.y 0 camR.y 0 camF camF.normalized camR camR.normalized transform.position (camF vec.y camR vec.x) Time.deltaTime MoveSpeed That's how i do my movement, but i need to change it to Rigidbody.AddForce 'cause the way that i use right now makes my character doesn't collide with objects perfectly. Note What i mean with "perfectly" is, if you walk to the corner of walls, you can pass through it and that's the thing that i want to prevent.
0
What are my options for building a centralized server architecture for a Unity game? I have made in the past multiple offline game, and would like to make my first online game. I have very basic knowledge of server structure. The game is a multiplayer RTS game, with ONE server (If possible in c ), where player can build base, attack other player and move around a world. it is in real time, but slow paced, so not many actions, and every time a user make movement it take let's say an hour to move. The game is planned for Android iOS and (maybe) but not at all for the moment, web. The game itself is easy, but the server I don't know where to start and I have been struggling in the last 3 days to find a informations and answer to my question. Most of the example I found are P2P client hosted server, this do not apply to my case, I want a single server that runs outside of Unity and that I can run on a computer as stand alone. My question problems are. 1) for a mobile game, I have seen in some post that UDP TCP Socket are not available in 3g? is this true ? If so, what should I Use ? I was thinking of websocket since MAYBE i make a web version, but I don't know if it's a good idea, and apparently it is not built in in Unity. 2) Related to my 2) is there any c library that work in Unity and would fit my game needs? a user would probably load a map, and interact around 20 times with the server during the gameplay. I believe a simple server that get and send message only is largely enough, but I don't know what to use. Start from scratch? then what should I use, TCP ? Socket? WebSocket ? 3) Should I use photon ? I've seen is free to test until 20CCU, and since for probably the next 6month I will be alone on it it's OK, then at release let's say I have 100 player, is not that expensive. Is it a viable solution? I found it a bit overkill for my needs, but it looks documented and easy to start. Will I still learn stuff if I "cheat" like this? Thank you for your time
0
How can I stop Substance's runtime texture caching? Procedural textures with the Substance Engine seem to update very quickly if you turn off caching, modify one exposed variable at a time, modify it frequently, and even then only after you've attempted to modify it 2 or 3 times. However, I want basically the opposite. For example, units have a "blood" variable that generates blood differently on them as they take damage, as well as a "battle wear" variable that generates scratches and dents, but doesn't revert when they heal. So to force a variable not to cache, I have to set it to some dummy value, then back to normal, then call RebuildTexturesImmediately. How can I tell Substance not to cache a variable at runtime, so I can change it once and have the texture regenerate quickly?
0
Unity3D How to play 360 video without VR mode? i followed the official Unity tutorial to make an inverted sphere and play a 360 video inside it and i managed to do it but the problem is i can't build the project to my phone because it says i have to turn on virtual reality support from player settings but the thing is i don't want to because when i do that it also turns on VR mode(that split screen view). what i want is to play a normal 360 video(full screen) and navigate using the gyro of phone just like Youtube. Youtube provides a button to toggle between headset and non headset mode.
0
How to change object curve path in playmode in Unity? I would like to make some sort of this simulation below, where user can interact with the white rod and drag it into the magnetic fields, which in resulting the blue line that represent the magnetic field of the permanent magnet to move in semi circular motion. I managed to get that kind of effect using animation I wish I do not have to make an animation for it by manipulation path for the sphere to be automatically correcting it's own path after colliding with the round object since the sphere will suddenly moving faster than usual when colliding with much bigger round object. I have tried using splines etc, but most tutorial I've seen are not editable in play mode, which is I cannot alter any of the curve values inside my script. So can anyone could provide me some insight or another better alternative than this? I've been stuck here for three days now. Thanks! EDIT
0
Change item rotation axis in inventory item visualization I'm learning unity and i'm trying now make an inventory, i made a simple interface, and now i'm trying to make a item visualization. I look for some codes from web and i found this one using UnityEngine public class TurnObject MonoBehaviour protected Vector3 posLastFame public Camera UICam Update is called once per frame void Update() if(Input.GetMouseButtonDown(0)) posLastFame Input.mousePosition if (Input.GetMouseButton(0)) var delta Input.mousePosition posLastFame posLastFame Input.mousePosition var axis Quaternion.AngleAxis( 90f, Vector3.forward) delta transform.rotation Quaternion.AngleAxis(delta.magnitude 0.1f, axis) transform.rotation I know some code, but I'm not good with geometrics. In this code when I move my mouse horizontal way, my object turn in the Y axis. And that's good. But when I move my mouse vertical the object move in the X axis instead of Z axis. Is there a way in this code for change this? I really have difficulty to understanding geometrics in Unity.
0
Help with Javascript touch button I tried many buttons but I can't connect them with the (Java)Script. So I made 2 gui buttons one for jump which was easy because I have an if statement and if it's true then jump. But I have problems with the crouch button. Bellow is my script but I can't figure out how I can do this from Update in function Gui. (Or if you know how to connect buttons with JS functions, please tell me it's always a better option D ) This is my script pragma strict private var tr Transform private var dist float distance to ground function Start() tr transform var ch CharacterController GetComponent(CharacterController) dist ch.height 2 calculate distance to ground function Update() var vScale 1.0 if (Input.GetKey("s")) vScale 0.5 var ultScale tr.localScale.y tr.localScale.y Mathf.Lerp(tr.localScale.y, vScale, 5 Time.deltaTime) tr.position.y dist (tr.localScale.y ultScale) function OnGUI () if(GUI.Button(new Rect(15, 330, 200, 100), "Shrink"))
0
How to switch between sprites in Unity So I made an empty game object in inspector, called it "squareTest", and I clicked and dragged 3 sprites in. One is the square being black, one is the square being red, and one is the square being green. What I want to do is this In the code, it starts by default as the black sprite. Whenever 'x' happens, the sprite changes to the red square. And whenever 'y' happens, it changes to the green square. BTW, x and y could mean anything. I just want some logic to it, as in if (password "Open sesame") Change square color My game programming experience is from Pygame, and this problem could have been solved like this (using a sprite sheet that goes from left to right) if Condition square spritesheet.current frame 5 screen.blit(square spritesheet.texture, (x, y), (self.current frame self.frame width, 0, self.frame width, self.frame height)) screen.blit goes (image, (x, y), (start chopping X, start chopping Y, end chopping X, end chopping Y) Unfortunately, I do not have a clue how this could be accomplished in Unity. I do not know if this is possible with an animator controller. I just want to know if this is possible, and how it could be achieved, with or without an animator. Thank you very much! The different colored squares are different textures, and I do not need transitions between states.
0
Quaternion.LookRotation with Joystick I am having an issue i cannot seem to figure out within my code. What this code does at the moment is that it rotates the 3D Model around the z axis but i need it to rotate around the y axis. Any help would be greatly appreciated. void Update () Vector3 moveVector (Vector3.up joystick.Horizontal Vector3.left joystick.Vertical) if (joystick.Horizontal ! 0 joystick.Vertical ! 0) transform.rotation Quaternion.LookRotation(Vector3.forward, moveVector)
0
Get all OffMeshLink objects in Unity What I'm trying to do is to make an edit mode script that gets all off mesh links and makes some of them bi directional(depends whether a jump is possible). My (obvious) attempt was FindObjectsOfType lt OffMeshLink gt () However, it returns only the links I have created manually. My question is the following how to access the off mesh links generated by unity in the baked NavMesh? Any help would be greatly appreciated.
0
Find position in arc depending on the direction of the agent So what I am trying to do is to find a random point on the (green quot ) arc around the enemy Sorry for the bad drawing but Red (no go) Green ( Points the allied can go to) I know that unity has the following function Radius 5 randomDirection (Random.insideUnitCircle target.position).normalized Vector3 finalPosition target randomDirection Radius However, this is for a full circle. How can I achieve the closest half circle?
0
Visually updating the position of a game object controlled by an animator controller I have a game object that is controlled by an animator controller. In order to activate the next animator state, the user is supposed to grab this game object, and then move it from Point A to Point B. As a test, in said game object's Update() method, I added the following line this.transform.localPosition Vector3.up When running the game, I can see that the y coordinate of the game object's position increases every single frame, just as intended. However, visually, the game object's position is not changing at all it remains in the same place all the time. What should I do to ensure that game object's position is also visually updated? EDIT Here are the properties of the animator I am using EDIT If relevant, here is the skinned mesh renderer for said game object
0
Unity3d High level literature Is there any high level literature for mid professional programmers for Unity? There are a lot of tutorials for beginners, but I can't find anything about main API, pipeline or engine architecture. Recommend, please!
0
I need to access a variable from another script in Unity I have been trying to aimlessly make a unity game around a 3d aim trainer and I have been trying to set up the targets that pop up. For now, I just wanted to create targets that pop up once every second at a maximum of 3 targets at one time ever. I have already set up the random spawn of the targets and the removal of them with the help of raycast shooting and made a max of 3 targets, however, to make the max of 3 targets I used an integer with a simple targetCount 1 and the deletion of the target is being done on a different script as seen below. My problem is making the targets respawn once being shot after spawning the first 3 targets. I tried to use getComponent to reach the targetCount variable in my Target code to just simply targetCount 1 every time I delete a target so that as long as the variable doesn't reach 3, it will continue to spawn targets however I was having some troubles. Please let me know if you have any ideas This is my target spawning code using System.Collections using System.Collections.Generic using UnityEngine public class GenerateEnemies MonoBehaviour public GameObject theTarget public float xPos public float yPos public int targetCount 0 void Start() StartCoroutine(TargetDrop()) IEnumerator TargetDrop() while (targetCount lt 3) xPos Random.Range( 6, 11.5f) yPos Random.Range(2.4f, 9) Instantiate(theTarget, new Vector3(xPos, yPos, 13.5f), Quaternion.identity) yield return new WaitForSeconds(1) targetCount 1 And this is my Code attached to my target using System.Collections using System.Collections.Generic using UnityEngine public class Target MonoBehaviour, IDamageable SerializeField private TargetStats targetStats private int currentHealth public GenerateEnemies generateEnemies private void Awake() generateEnemies GetComponent lt GenerateEnemies gt () private void Start() currentHealth targetStats.maxHealth public void DealDamage(int damage) currentHealth damage CheckIfDead() private void CheckIfDead() if(currentHealth lt 0) Destroy(gameObject) GenerateEnemies.targetCount 1
0
AudioClip is empty saving recording from Microphone EDIT I updated the code to what I have currently. I'm not sure why but, the editor and my platform complained when I put the WWW in a co routine, it seems to load the audio clips to the object but I cannot play them. In a script attached to the object I wait until the Audio Clip is loaded before I try to play it. So I am trying to record some Audio through the microphone and then save an AudioClip to the disk as a .wav file and also save the filepath as a playerpref and then later I can come back and load the string into a url but, for some reason the Audio Clip doesn't get loaded properly as I can see that there is an audio clip on my audio source in runtime but, it has no name and it has no sound on it. However, when I press play in the inspector I can hear my sound I am using SavWav.cs to save my audio clips to .wav files. Here is the url(filepath) I am sending to my load method string filename string.Format( "CapturedAudio 0 n.wav", Time.time) string filepath Path.Combine(Application.dataPath, filename) Here is the method I am using to get the AudioClip private void SpawnObject(string savedNames, Vector3 savedPositions, Quaternion savedRotations) GameObject cubeToSpawn Instantiate(cube, savedPositions, savedRotations) WWW www new WWW("file " savedNames) cubeToSpawn.GetComponent lt AudioSource gt ().clip www.GetAudioClip(false, false, AudioType.WAV) The obj is just a cube with an AudioSource attached to it that I instantiate prior to calling this method above. The filepath works fine for saving but, for some reason it doesn't want to load the audio clip. Any help would be greatly appreciated.
0
Code optimalization Mass selecting units (RTS) Yo fellow game developers! So recently gamedev became my favorite hobby and I started working on my RTS game module which would then let me create different RTS games with just few changes (W3 inpiration 3). Anyway I am new to optimalization since my previous games had quite serious optimalization issues so I need your help with a pieace of code! I am having a mass selection of units with drawn rectangle on screen. I've got it all worked out but now I am wondering if there could be anything done about optimalization for cycling through list of units every time my mouse position changes even for a little bit. This is inside my Update function. There is much more in there so i cut it out but this is the piece I am worried about void Update() ...previous code blah blah blah... if (Input.GetMouseButton(0)) oldPos2 point2 point2 Input.mousePosition if (oldPos2! point2) performance optimalization Debug.Log ("Performing selection") if (Vector2.Distance(point1,point2) gt selBoxIniDist) isSelecting true foreach (var item in Game.Units) if (IsWithinSelectionBounds (item.gameObject)) item.Selected true else item.Selected false ...rest of the code here... So as i told you, there is no problem with the code. I just need your opinion if there could be any changes especialy to this part of the code. Or maybe general advices for optimalization. Even tho I am checking every update if the mouse moved (so I dont cycle every update) I still feel like checking every "milimeter" 5 times if any of the units are contained in the viewport rectangle is a little bit overkill just for the selecting units. At the end of selection I usualy end up with around less than 100 cycles. What do you think? EDIT I might as well add a method that checks if the unit is in the viewport bounds and a utility method that calculate the bounds. Just so you why I am worried about performance. Checking if bounds contain unit public bool IsWithinSelectionBounds( GameObject gameObject ) if (!isSelecting) return false var camera Camera.main var viewportBounds Utilities.GetViewportBounds( camera, point1, point2) return viewportBounds.Contains(camera.WorldToViewportPoint(gameObject.transform.position)) Static utilities public static Bounds GetViewportBounds( Camera camera, Vector2 screenPosition1, Vector2 screenPosition2 ) var cam Camera.main var v1 cam.ScreenToViewportPoint( screenPosition1 ) var v2 cam.ScreenToViewportPoint( screenPosition2 ) var min Vector3.Min( v1, v2 ) var max Vector3.Max( v1, v2 ) min.z camera.nearClipPlane max.z camera.farClipPlane var bounds new Bounds() bounds.SetMinMax( min, max ) return bounds
0
simple 2d car AI unity I have a top down Car Game. how can I implement AI for the Cars? how the car follow the way points? I want AI cars also rotate itself along the path. I tried this solution using System.Collections using System.Collections.Generic using UnityEngine public class waypoint MonoBehaviour public List lt Transform gt waypoints private Transform currentWaypoint public float speed 5f private float closeEnouth 0.5f int point 0 void Start() currentWaypoint waypoints point Update is called once per frame void Update() Quaternion rotation Quaternion.LookRotation(waypoints point .position transform.position, transform.TransformDirection(Vector3.forward)) transform.rotation new Quaternion(0, 0, rotation.z, rotation.w) float dist Vector3.Distance(waypoints point .position, transform.position) transform.position Vector3.MoveTowards(transform.position, waypoints point .position, Time.deltaTime speed) if (Vector3.Distance(this.transform.position, waypoints point .position) lt closeEnouth) if (point 1 lt waypoints.Count) point and the car moved in the path but it moves reversed and if arrives the final node it stops and corrects its direction and console displays "Look rotation viewing vector is zero" error. Thanks in advance
0
Populate triangles array when you already have sorted vertices array Input is a Vector3 of verticies. Length is unknown, it could be anything above 2 so these vertices form all kinds of multifaceted shapes with 3 being a triangle and 6 hexagon ish. Poor example to visualize vertices Vector3(..), Vector3(..), Vector3(..), Vector3(..), Vector3(..) Coordinates in that array are ordered counterclockwise. I also have the coordinates of center point that these verticies form (look at illustration below) it doesn't have to be used but if it helps.. Few examples of which shapes can occur and which cannot Now I need to build meshes out of them. For each shape I need Vertices array (which I already have, nicely ordered) Triangles array 3 indices (from vertices array) per triangle until all vertices are covered How to populate triangles array with these relatively easy shapes where each vertex has "direct line of sight" to every other vertices? Number of vertices is unknown of course.
0
Lerp UI Color outside update method? I'm able to Lerp the color of a UI panel within the Update method. However I'd like to trigger behavior a single time when needed. If I put it in a method and call it it only changes for a brief time and doesn't fully complete. I could probably set a bool flag within the update method but that seems sloppy.
0
ScriptableObjects events execution order? Given the code CreateAssetMenu(fileName quot newGameManagerInstance quot , menuName quot Game Game Manager Instance quot ) public class GameManagerSO ScriptableObject private GameManager instance public GameManager Instance get return instance set instance value private void Awake() Debug.Log( quot 1 quot ) private void OnEnable() Debug.Log( quot 2 quot ) private void OnDisable() Debug.Log( quot 3 quot ) private void OnDestroy() Debug.Log( quot 4 quot ) I have two questions Why the output in console when I enter play mode is quot 3 quot and then quot 2 quot ? Shouldn't OnDisable be executed after OnEnable? I'm using this scriptable object to hold an object reference only (I don't have the need to serialize the object, it's just a handy way I found to pass that reference through scenes without committing to singletons) can I code all initialization code for the object in OnEnable method? Can I assume it will always execute before any MonoBehaviour read it? Also
0
Quat.AngleAxis broken on one axis I have a scene in my game where you create your own designs by placing static meshes and manipulating their scales, positions, and rotations. For the rotations I'm using Quaterion.AngleAxis as so if (toolMode PositioningTool.Rotate) switch (grabbedCollider.transform.name) case "X" focus.localRotation Quaternion.AngleAxis(delta.x 90 Time.deltaTime, transform.right) break case "Y" focus.localRotation Quaternion.AngleAxis(delta.x 90 Time.deltaTime, transform.up) break case "Z" focus.localRotation Quaternion.AngleAxis(delta.x 90 Time.deltaTime, transform.forward) break where delta is the mouse movement for that frame, focus is the object I am manipulating, and transform is the transform component of the ToolArm that the player interacts with. toolarm.position is set to focus.position every frame my problem arises when I try to do a rotation on my x axis. my other axis will spin 360 and beyond, spinning in circles endlessly. when x axis is used, it only rotates from 90 to 90 (as seen in the unity editor). What am I doing wrong?
0
How to render a grid of dots being exactly 1x1 pixel wide using a shader? I would like to render a grid with many dots, all equally spaced and being exactly 1 pixel wide. What I was able to achieve so far is this What I would like is (simulated using image editing program) Here is the shader I wrote (which give result of 1st image). This is rendered as a giant quad. Shader quot Custom Grid quot SubShader Pass CGPROGRAM pragma vertex vert pragma fragment frag include quot UnityCG.cginc quot struct vertInput float4 pos POSITION float4 uv TEXCOORD1 struct vertOutput float4 pos SV POSITION float4 uv TEXCOORD0 vertOutput vert (vertInput input) vertOutput o o.pos mul(UNITY MATRIX MVP, input.pos) o.uv input.uv return o fixed4 frag (vertOutput output) SV Target float4 uv output.uv float x step((uv.x 100.0 0.025) 1.0, 0.05) float y step((uv.y 100.0 0.025) 1.0, 0.05) float c min(x, y) return float4(c, c, c, 1.0) ENDCG Is it possible to achieve what I want using a shader ? What is needed from first draft is to control the size of each dot. I have tried to use partial derivatives (ddx and ddy) but was not able to make it work.
0
Synchronize objects' movements moved by coroutine function I'm using Unity version 5.3.5. I'm having problems to synchronize the movement of three different objects from point A to point B and vice versa. To move the objects I use the following code public float time public Vector3 endPos private Vector3 startPos void Start() startPos transform.position void FixedUpdate() if(transform.position startPos) StartCoroutine(Move(gameObject.transform, startPos, endPos, time)) if(transform.position endPos) StartCoroutine(Move(gameObject.transform, endPos, startPos, time)) public IEnumerator Move(Transform thisTransform, Vector3 startPosition, Vector3 endPosition, float time) float i 0f float rate 1 (time) while(i lt 1) i Time.deltaTime rate thisTransform.position Vector3.Lerp(startPosition, endPosition, i) yield return null As long as all of the objects have the same "time" value, their movements is correctly synchronized regardless the distance that they have to cover. The problems arises when they all have different "time" value. For example, if they have to move backwards and forwards from startPos(0,0,0) and endPos(5,0,0) with the following "time" value Object A time 1 second Object B time 2 second Object C time 4 second After 4 second, they should all be again at the same start position. However, what happen is that the fastest object (Object A) has a delay over the other two and this delay increase over time. How can i fix this problem?
0
How can I keep two racing players synchronised? I am working on a Unity mobile game, much like a multiplayer version of Temple Run. I'm seeing a fluctuating network latency (generally 200 500ms) because of the mobile platform. The two player characters are shown as running along the same path and must do simple actions (jump, slide, powerup, etc.) to pass obstacles. When a message comes late, the game assumes the remote player passed an obstacle. This usually works well, but in case a player is killed by an obstacle, I want the remote player to appear to die on the same obstacle position as local player. Due to latency, the remote player appears to have crossed the obstacle before the message announcing their death even arrives. How can I keep the players synchronised? I tried moving the remote player back to the local players death position immediately as the death message arrives, it looks awkward visually and might raise other syncing issues.
0
How can I implement a more realistic momentum system in Unity 4.5? I'm just starting out with Unity and am making a simple environment where there is a sphere and a ramp. When the sphere approaches the ramp everything is fine. As soon as the sphere hits the ramp is where I'm having trouble the velocity is instantly reduced and when it goes off the end of the ramp, instantly returns to the velocity as though it were on the ground. I'm not sure if this can be changed by some settings in Unity or I would have to write some code. Here's the physics code I have so far (in C ) public class PlayerController MonoBehaviour public float speed void FixedUpdate() float moveHorizontal Input.GetAxis("Horizontal") float moveVertical Input.GetAxis("Vertical") Vector3 movement new Vector3(moveHorizontal, 0.0f, moveVertical) rigidbody.AddForce(movement speed Time.deltaTime)
0
Rotate smoothly object to angle (Y axis) of the collided object Well, let's say I have two planes, one which I am moving, and another one that I collide with, that has a different y rotation. I want to make that, once both planes collide, the plane the user controls changes it s rotation to the collided plane rotation.I ve achieved it simply equaling both planes transform.rotations, but that was just a testing, i would like to rotate the plane smoothly. I have tried with eulerAngles, and Quaternion.Lerps, but it doesn t work, or I am not following well the sintaxis. I know that a rotation and the eulerAngles are different values. There seems to be a solution with the dotween scripts, but I would like to learn the right approach to do it, rather than make it directly with dotween. Here I paste the trigger enter code, with the methods I tried (are commented). I guess that the rotation origin would be another issue. void OnTriggerEnter(Collider col) if (col.gameObject.tag "Plane") Debug.Log ("Yup...Angle " col.gameObject.transform.rotation.y) this.transform.rotation col.gameObject.transform.rotation newAngle 0 (this.transform.eulerAngles.x, col.gameObject.transform.eulerAngles.y, this.transform.eulerAngles.z) this.transform.eulerAngles(newAngle, 2 Time.deltaTime) this.transform.rotation Quaternion.Lerp (this.transform.rotation, col.gameObject.transform.rotation, Time.deltaTime 0.1f)
0
How do I make night cycle like Dino Chrome? I want to add a day night system cycling to my runner game like the game Dino Chrome. The condition is when the score reaches 100 it will be night then when it reaches 100 again will be day. I tried with this code but nothing changed in my game if ( GameManager.instance.score 100 0) fadeToBlack !fadeFromBlack if (fadeToBlack) cam.backgroundColor new Color(Mathf.MoveTowards(cam.backgroundColor.r, 1f, fadeSpeed Time.deltaTime), Mathf.MoveTowards(cam.backgroundColor.g, 1f, fadeSpeed Time.deltaTime), Mathf.MoveTowards(cam.backgroundColor.b, 1f, fadeSpeed Time.deltaTime), cam.backgroundColor.a) if (fadeFromBlack) cam.backgroundColor new Color(Mathf.MoveTowards(cam.backgroundColor.r, 255f, fadeSpeed Time.deltaTime), Mathf.MoveTowards(cam.backgroundColor.g, 255f, fadeSpeed Time.deltaTime), Mathf.MoveTowards(cam.backgroundColor.b, 255f, fadeSpeed Time.deltaTime), cam.backgroundColor.a) Eventually I want to change all game object colors via script with smooth, but for now I just want to apply a change to the camera background. and this is my whole script public static ObstacleManager instance private void Awake() instance this public float maxTime float timer Header( quot CommongObstacle quot ) public GameObject Obstacles Header( quot BirdObstacle quot ) public GameObject buwungObstacle Header( quot MeteorObstacle quot ) public GameObject Meteor public Transform spawnpoint int choosedSpawnMeteor int choosedObstacle Header( quot NightCycle quot ) public float fadeSpeed 2f public bool fadeToBlack, fadeFromBlack public Camera cam Start is called before the first frame update void Start() cam GetComponent lt Camera gt () Update is called once per frame void Update() if ( GameManager.instance.isStarted) timer Time.deltaTime if (timer gt maxTime) GenerateObstacle() if ( GameManager.instance.score gt 400) GenerateBuwungObstacle() timer 0 if ( GameManager.instance.score 100 0 amp amp activeFade null) fadeToBlack !fadeToBlack Color color fadeToBlack ? Color.black Color.white activeFade StartCoroutine(FadeTo(color)) kelipatan 200 public void GeneratedMeteorObs() choosedSpawnMeteor Random.Range(0, spawnpoint.Length) GameObject meteorGo Instantiate(Meteor, spawnpoint choosedSpawnMeteor .position, Quaternion.identity) public void GenerateObstacle() choosedObstacle Random.Range(0, Obstacles.Length) GameObject obstacle Instantiate(Obstacles choosedObstacle ) public void GenerateBuwungObstacle() choosedObstacle Random.Range(0, buwungObstacle.Length) GameObject obstacle Instantiate(buwungObstacle choosedObstacle ) Store the fade in progress (so we don't accidentally double start it) Coroutine activeFade Perform a fade over time, then clear the activeFade variable when done. IEnumerator FadeTo(Color destination) Color start cam.backgroundColor for (float t 0 t lt 1f t Time.deltaTime fadeSpeed) cam.backgroundColor Color.Lerp(start, destination, t) yield return null cam.backgroundColor destination activeFade null
0
RPC's in Legacy Unity, what to use in Unity 5.1? I have created a small experiment in 5.1, a server has an AI character pathfinding around a map over a grid, so its a straight line node to node before it reaches the end. I would like for the client to also view this pathfinding character. Using the networking scripts built in it sends fine, however the client see's a stuttering character and not something smooth like the server sees. So my solution to this is that when the server calculates the new node for the character to go to that the location of this node is sent to the client, the client moves its character to the node and so on. So instead of constant transform data being sent, the clients AI can go to the node and wait for the next node location to be sent, therefore being smooth. In previous versions of Unity I would've used RPC's, but this is labelled as Legacy now, what can I use now to send a node location from the server to the client?
0
Unity how to remove standard sky but keep the lighting? How can I remove the standard Unity sky (to have an empty space with no texture around my scene), but keep all the lighting effects from it?
0
How to add time delay in Unity C So I'm trying to make a camera zoom in, but Thread.Sleep doesn't work. Here is the code void Start() for (int a 0 a gt 1000 a a 1) Debug.Log( quot Done! quot ) Thread.Sleep(100) The error code is this Assets StartScene CamScript.cs(12,13) error CS0103 The name 'Thread' does not exist in the current context
0
Set a minimum distance with navmeshagent I am totally newb. How to set a minimum distance between AI chasing a player if AI has navmeshagent if (Vector3.Distance(transform.position, target.position) gt minDistance) enemy.destination player.position What I need is it works similar to this code below if (Vector3.Distance(transform.position, player.position) gt minDistance) transform.position Vector3.MoveTowards(transform.position, player.position, moveSpeed Time.deltaTime) But using destination property or SetDestination
0
Aligning a sprite with a tilemap I'm trying to create a hybrid system for my Unity game. I want to use tilemap for collision and use sprites for the world. I drew a sprite onto a 40x40 checkerboard grid as can be seen here. I wanted an easy way to create a collider for this without spending 30 minutes hand placing box colliders and I decided to use a tilemap to place red tiles and use a tilemap collider for collision geometry and just hide the red tiles in game. Issue is, I have no clue how to align the checkerboard with the Unity tilemap grid. Here's a screenshot of the sprite in the unity editor with the tilemap grid visible. If it isn't obvious, then the white lines is the grid for the tilemaps. The cellsize for each cell on the grid isn't the same size as the cells on the checkerboard pattern and I have no idea how to fix it. The PPU (pixels per unit) of the sprite is 140. The PPU for the tileset tile(singular since there is literally only 1 tile in the entire tileset) is also 140. The checkerboard in paint.net is 40x40 and so is the tile. How can I get the cellsize of the grid in unity to match the cell size of the checkerboard.
0
Local avoidance together with any angle types of A Pathfinding Recently I have been implementing the Block A any angle path finding algorithm in a project I have, for which I need extremely efficient results due to the large number of NPCs. However, I still do not know exactly how to handle the problem of local avoidance between the NPCs moving at the same time in the same scene. So, my question is this what is the best method to implement local avoidance with any angle path finding? Just testing for LOS and steering to the tangent of the predicted encounter is a good enough solution or should a specific AI implementation be included within the pathfinding routine? I would highly appreciate references (academical or not) with state of the art implementations of local avoidance for me to explore the most recent developments in that field. Many thanks.
0
How do I work around the "You are missing the recommended JDK" error? After switching to 2019.4 LTS I got this error (using Windows 10) You are missing the recommended JDK. Install the recommended version using Unity Hub. I installed the JDK using Unity Hub many times now, still the same error. Tho I don't think it's getting installed. As you can see below, the quot OpenJDK quot checkbox remains blue no matter how many I try to install it. When I tried downloading and installing the JDK (JDK 1.8.0 181) myself I get this error instead You are missing the recommended JDK, versions other than 1.8.0 are not officially supported.
0
Unity General Prefab I have 2 questions about how i should approach this. I want to make a 2D game, with alot of different creatures. Question one If i have alot of monsters and i'm using ScriptableObjects, since they have very similar variables. How can i make one Enemy prefab which will load the right ScriptableObject information? For example i have an Enemy Prefab, then it will load random monster between Dragon, Frog, Wolf. How can i achive this without creating 3 new Prefabs for each one and instead load just the right ScriptableObject. Question two Should i create new prefab for each monster? Or is approach 1 the right way to do it, if you plan to expand over 100 creatures. Thanks
0
Persisting unlocked characters in Player Prefs I am working on a character selection menu in Unity. If you have enough coins, you can buy your desired character. Once player buys one, that character must not be locked on game restart, the number of coins must not be changed again, and the lock image (a GameObject I defined under name "wood" and acts as a lock) must disappear. Everything works fine when I buy one character, but when I buy another one, the previous one returns to locked mode, but its image (wood) has already disappeared (I mean, I should have enough coins to re buy an already bought character). I guess there must be something wrong with this code isPlanesold PlayerPrefs.GetInt("isPlanesold") because it changes as a character is bought. Here is my script int isPlanesold public static int chnum character number that must be referenced on another scene public Button WhitePlane public Button YellowPlane public GameObject wood1 public GameObject wood2 void Start () PlayerPrefs.SetString ("BluePlane", "on") if (PlayerPrefs.GetString ("WhitePlane") "on") wood1.SetActive (false) if (PlayerPrefs.GetString ("YellowPlane") "on") wood2.SetActive (false) UIManager2.coin score PlayerPrefs.GetInt ("Score") isPlanesold PlayerPrefs.GetInt ("isPlanesold") public void BuyWhitePlane () if (isPlanesold 1) PlayerPrefs.SetInt ("isPlanesold", 1) chnum 2 PlayerPrefs.Save () SceneManager.LoadScene ("Menu2") else if (UIManager2.coin score gt 1) PlayerPrefs.SetInt ("isPlanesold", 1) chnum 2 PlayerPrefs.SetInt ("Score", UIManager2.coin score ) PlayerPrefs.SetInt ("Score", UIManager2.coin score) PlayerPrefs.Save () PlayerPrefs.SetString ("WhitePlane", "on") SceneManager.LoadScene ("Menu2") else Debug.Log ("You Don't Have The Score") public void BuyYellowPlane () if (isPlanesold 2) PlayerPrefs.SetInt ("isPlanesold", 2) chnum 3 PlayerPrefs.Save () SceneManager.LoadScene ("Menu2") else if (UIManager2.coin score gt 2) PlayerPrefs.SetInt ("isPlanesold", 2) chnum 3 PlayerPrefs.SetInt ("Score", UIManager2.coin score 2) PlayerPrefs.SetInt ("Score", UIManager2.coin score) PlayerPrefs.Save () PlayerPrefs.SetString ("YellowPlane", "on") SceneManager.LoadScene ("Menu2") else Debug.Log ("You Don't Have The Score") PlayerPrefs.SetString ("BluePlane", "on") refers to a character that's unlocked by default.
0
How to enable antialiasing for SVG Images? My game has vector icons and sprites, like this one Its quality disappoints me. I guess that antialiasing is disabled here for some reason, but have no idea how to turn it on. The problem is only with UI component SVG Image. Sprite Renderer seems to not have this issue Regular Image does not support vector icons. I tried this approach. MSAA is enabled on Camera and in Quality settings. When it's disabled, second sprite becomes exactly the same as first. Unity version 2018.2.7.f1 for Linux Vector graphics package version 1.0.0 preview.23 I will accept a solution or an optimal workaround of any complexity. But please don't suggest using raster images. Why? I have to compress them because the game is for WebGL and I already had problems with memory because of textures. Vector sprites take less memory. Without mipmaps icons are pixelated. With mipmaps, they look blurry. They are all power of two, but at different scales. They are even blurred different, some more, some less. I can't use fixed sized sprites because there's an animation that changes zoom, and canvas will rescale in fullscreen. Vector guns are to the left, raster ones with mipmaps to the right. Thin black border lines are gone.
0
Why won't my block Spaces Holders hold my blocks when I drag onto them in Unity? In my game I am trying to have numbered blocks and math operators be able to be dragged down into their respectively color coded holders (white holders Numbers, black holders operations). The spawn in color coded blocks called spawners. If you drop a block you were dragging in a space that isn't a holder, then the block would immediately snap back to its respective spawner. However, I am now encountering this issue where 99 of the time when I drop the block onto its respective holder, the block snaps back to its spawner instead of staying there. Here's the minimum reproducible code for dragging the blocks using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.EventSystems RequireComponent(typeof(Collider2D)) public class DragDrop MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler SerializeField private SpriteRenderer spriteRenderer public SpriteRenderer SpriteRenderer gt this. spriteRenderer HideInInspector public static bool isInSpace HideInInspector public Vector3 initialPos private void Start() initialPos transform.position isInSpace true public void OnDrag(PointerEventData eventData) if (isInSpace false) Vector3 movement new Vector3( x (eventData.delta.x 3) Time.deltaTime, y (eventData.delta.y 3) Time.deltaTime) this.transform.localPosition movement public void OnBeginDrag(PointerEventData eventData) isInSpace false public void OnEndDrag(PointerEventData eventData) if (isInSpace false) transform.position initialPos if UNITY EDITOR private void Reset() this. spriteRenderer this.GetComponent lt SpriteRenderer gt () endif And Here's the code for receiving the blocks using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.EventSystems public class RecieveBlock MonoBehaviour, IDropHandler public void OnDrop(PointerEventData Block) if (Block.pointerDrag ! null amp amp Block.pointerDrag.tag gameObject.tag) Block.pointerDrag.GetComponent lt RectTransform gt ().anchoredPosition GetComponent lt RectTransform gt ().anchoredPosition DragDrop.isInSpace true I have no idea why it doesn't set off the isInSpace bool to be true and stay there. Heirarchy Image For Number Blocks Heirarchy Image For Operation Blocks Heirarchy Image For Holder Blocks Thank you for reading.
0
Unity Copy another object's Y location? I'm creating a Pong clone inside of Unity and was trying to figure how to copy another object (In this case being the Y co od of the Ball Object) How would i go about doing this? I'm using vectors as my method of paddle movement and I want to create a public int AISpeed so that the AI paddle is a little slower in comparison In my mind I assumed it was along the lines of rightPaddle.location.y pongBall.location.y How would I create this?
0
Fail to install ML Agents (python packages) I have been trying for hours to install pytorch and mlagents with cmd, however I am getting pretty much the same error for each package I'm trying to install ERROR Could not find a version that satisfies the requirement typing extensions (from torch 1.7.0) (from versions none) ERROR No matching distribution found for typing extensions (from torch 1.7.0) I'm using python version 3.7.9, attaching a screenshot of the cmd. Also, as you can probably notice I'm getting a repeating warning every time I'm using pip and I'm not sure of it's something to avoid WARNING Retrying (Retry(total 0, connect None, read None, redirect None, status None)) after connection broken by 'ReadTimeoutError( quot HTTPSConnectionPool(host 'pypi.org', port 443) Read timed out. (read timeout 15) quot )' simple torch
0
Empty game object (child of player) not changing position correctly when key pressed I've made an empty game object which is the child of the player. It is by default on his right side and following his every move, and I want to make it so that every time a directional key is pressed (WASD) it changes position and stays there. But the way I've made it, it's not working as intended and seemingly goes to random positions every time. Here's the script using System.Collections using System.Collections.Generic using UnityEngine public class ChangePositionAccordingToKey MonoBehaviour Start is called before the first frame update void Start() Update is called once per frame void Update() if (Input.GetKeyDown(KeyCode.W)) transform.position new Vector3( 0.58f, 3.09f,0) This is probably a dumb question but I am new to coding so I can't figure it out. Any help is greatly appreciated
0
Can I use the 2d physics engine in a 3d game (or viceversa) in Unity? This is entirely for performance. The 2D physics are less expensive, but I require 3D for some scenes. I never need both at the same time. I know you can have 2D with an orthographic perspective in a 3D engine, but what I want is really the physics engine. Also, is there a way of turning off these engines? I ve made most collisions from scratch and am only using them for some raycasts at the beginning and for some collider rigidbody.casts in not every, but a lot of frames (If I understand correctly, they are calculated from the physics engine in each FixedUpdate()).
0
Unity Best Random Movement Strategy? As of now, to get random movement of my enemies, I am adding a Rigidbody and a BoxCollider then "throwing" them (i.e. adding velocity) in a random direction for a random amount of time and making them choose a new direction if ever they get outside of their designated area. This does not seem to work that well all the time. Sometimes they manage to get themselves stuck inside obstacles which should be impossible. The more I add guys, the more it seems the physics can't keep up or something with the collisions. Is there a better method to random movement or is "throwing" them perfectly valid? Is my method expensive and terrible? I might have around 50 guys active at a time and perhaps a few hundred to a thousand static obstacles each with their own colliders.
0
How to prevent collisions between instantiated prefabs I'm creating a virtual creature evolution system like here. This type of project requires to define creatures, which are made of some 3d boxes and simulate them over and over again, making little changes along the way, until the point where they are good enough at a certain task. Basically, I'm using Genetic algorithms. I'm going to be doing a lot of simulation (a few hundred creatures each generation, times X generations, where X could be in the thousands). In order to save time, I want to simulate multiple creatures at once, so I must run collision checks efficiently. Each creature exists on its own and therefore should not be bothered by other colliders except himself and the ground. I have a prefab of a creature. Each creature is made of multiple 3d boxes with colliders. The nodes in the same creature should collide with themselves but should not collide with nodes that are in other creatures (because it should learn to perform based on the environment as it is). What is the most efficient way I could do this? I thought about checking the root of the collision object but that just prevents the collision and doesn't eliminate the useless checks that are being made. I've also looked at solutions involving the "Layer Collision Matrix" but still could not find a way to make it work. Thanks in advance.
0
Smoothly resize minimap camera rect width and height I have an orthographic camera that is working as a mini map. Now I want to make it resizeable using mouse drag. I have applied some UI beside my minimap camera rect and those UI resizing perfectly with this code. But I have no clue that how to resize my camera rect with mouse drag void Awake() rectTransform transform.GetComponent lt RectTransform gt () public void OnPointerDown(PointerEventData data) if (!resizePanelFeatureActive) return rectTransform.SetAsLastSibling() RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, data.position, data.pressEventCamera, out previousPointerPosition) public void OnDrag(PointerEventData data) if (!resizePanelFeatureActive) return if (rectTransform null) return Vector2 sizeDelta rectTransform.sizeDelta RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, data.position, data.pressEventCamera, out currentPointerPosition) Vector2 resizeValue currentPointerPosition previousPointerPosition sizeDelta new Vector2(resizeValue.x, resizeValue.y) sizeDelta new Vector2( Mathf.Clamp(sizeDelta.x, minSize.x, maxSize.x), Mathf.Clamp(sizeDelta.y, minSize.y, maxSize.y) ) rectTransform.sizeDelta sizeDelta previousPointerPosition currentPointerPosition
0
SpriteRenderer batching issue, with Z Position and Order in Layer I have two sprites (they look the same but with different colors) I want them to be positioned like on the image above, so there's a feel like blue is standing on the green one. There are two ways to achieve that Blue block with Order in layer 1, Green block with Order in layer 0 Blue block with lower Z coordinate, so it's physically in front of the green one. Both of the concepts appear to break batching between these two objects. They're on the same atlas (I've tested it by setting the same Z position and Sorting Order and batching works). How can I achieve batching here?
0
Tracking how many people play my Unity game in which language? In my game the user can change the language of the game and I'd like to know how many people play it in English, German, etc. I'm using Unity, so possibly I would like to implement in Unity Analytics. I was thinking about adding segments for the languages, but in that case if a user tries all languages, the user will appear in all languages' segments. So it won't really provide that much info. A possible solution When the user changes language, we signal a database to decrease the old language's counter and increase the new language's counter. But there must be an easier, built in solution than this.
0
How to put a reference to my player (already instanced) into a prefab that will be instantiated later I'm making an enemy in my game. He stands at the side of road with a rocket launcher and fires when you get close. It nearly all works fine, except I just need a reference to the players position so that I can make his rocket explode when it reaches the same height on the map as the player car. The enemy is a prefab which is NOT instanced at build time, there a several spawn points all with n chance of spawning a guy there using the prefab. The player IS instanced at build time. And here is my problem.. Although I have put a "public GameObject player" into my variables in the script on the prefab, it doesnt let me drag the already instanced player into it. I've read about a bit, and I see that Unity will not allow this (or at least thats what I gathered!) So after much searching I came up with player GameObject.FindGameObjectWithTag("Player") But i havent even tested yet because the source where i got that advice in the very next comment the guy says I shouldnt do this because it takes too much system resources up. EDIT I have tested it with that line, it does work. But is there a better way But he doesnt say the way that it should be done! And the thread is about 6 years old. So I thought I'd write here again and ask you fine folks for more help. I hope I explained the problem clearly enough, I think i got the terminology right. Basically, the RocketerEnemy prefab is going to be instantiated in runtime, but the PlayerCar is already instantiated by my dragging it into the heirarchy at the beginning of the project. This is stopping me from dragging the PlayerCar object into the box in the Inspector (for the Enemy prefab) . All I really need is the PlayerCar.transform.position.Y value for each frame. THANKS IN ADVANCE !
0
How to delete a score after collecting all collectibles I'm making a small game for my English class, and in the beginning, you have to collect rocks. I already have the code for counting how many rocks have been picked up, and the GUI to display while the game runs. After the player collects all 9 rocks I would like for the GUI to disappear or delete itself since it won't be used anymore throughout the game, and for new text to appear at the top of the screen saying "Go To The Lottery" I'm still very new to Unity so posting the code, and then following up with a brief explanation as to what does what would be majorly appreciated (but not at all demanded) Both codes are in JavaScript pragma strict static var currentScore int 0 var offsetY float 40 var sizeX float 100 var SizeY float 40 function OnGUI () GUI.Box (new Rect (Screen.width 2 sizeX, offsetY, sizeX, SizeY), "Rocks Collected " currentScore) This is my GameMaster script, which is in a empty game object galled " GM" pragma strict function OnTriggerEnter (info Collider) if (info.name "Player") GameMaster.currentScore 1 Debug.Log ("Picked stone up") Destroy (gameObject) This is my RockCollection script and it's what actually tells the GameMaster script to add 1 to the score and then delete the rock so you can't continuously pick it up
0
How to make a rigidbody come to rest faster I'm trying to move around a 3D rigidbody in Unity 2018.1.0f2 Personal. I am using a C script with the basic vector3 and velocity stuff from a YouTube video using System.Collections using System.Collections.Generic using UnityEngine public class Player MonoBehaviour SerializeField private Rigidbody playerBody private Vector3 inputVector private float xMovement private float zMovement SerializeField private float playerSpeed private float maxSpeed Use this for initialization void Start () playerBody GetComponent lt Rigidbody gt () playerSpeed 1 Update is called once per frame void Update () xMovement Input.GetAxisRaw("Horizontal") playerSpeed zMovement Input.GetAxisRaw("Vertical") playerSpeed inputVector new Vector3(xMovement, playerBody.velocity.y, zMovement) playerBody.velocity inputVector It works great with a cube I put it on, except for this if I move the rigidbody and then stop, it takes a long time for it rotate from go only one of the edges or corners just touching the ground (screenshot of what I mean, another screenshot) to resting flat. How can I make it fall back to stability faster?
0
How can this method to make a text mesh always face the camera be simplified? (Unity c ) Despite a fairly heafty new years I am back trying to learn a bit more coding D This latest feature I am trying to add is a TextMesh that floats above a gameobject when the player is looking at it. I does all work fine (except it kinda shakes a little but I'll look into that another time). But as I wrote the method to make the textMeshObject look at my camera, I just had a niggling feeling it could be written in less lines of code. I actually get this a lot where I write several lines and think it must be able to be simplified, and after the code having several parts like this it can look pretty messed up. Anyways, I thought i'd ask you experts on here if it was possible to do this an simpler (NOTE I only want it to rotate on Y Axis) void FaceTextMeshToCamera() Vector3 origRot textMeshObject.transform.eulerAngles textMeshObject.transform.LookAt(textLookTargetTransform) Vector3 desiredRot textMeshObject.transform.eulerAngles desiredRot.x origRot.x desiredRot.z origRot.z textMeshObject.transform.eulerAngles desiredRot
0
What takes up more processing power between whole character models or models that are pieced together in Unity? In terms of performance when it comes to animation what takes up more processing power Whole character models or models that are pieced together? (1 object vs multiple objects). I also wonder if animating multiple objects allows us to get a better overall animation quality instead of working with one object (especially if we deal with action packed scenes).
0
Missing UI options in Inspector window when I import FBX files I am missing all the animation options in the Animation tab in the Inspector Window when importing FBX files. In the picture below, there are only 2 checkboxes. I can't see the list of animations, options, animation events etc., but you can see on the lower left window that the animations we're imported. Also, the Materials tab is empty as well. This FBX was exported from Blender. If I directly drag the .blend file to Unity, all those tabs appear normally, but when dragging an FBX, they become empty. I am using Unity 2019.3.0f6.
0
Problem with Blender model imported to Unity (Lighting problems) I made a simple box in blender and imported it to unity. Now I'm facing with this weird lighting problem I've been messing around with normals, duplicated vertex, lots of things, even lightning properties but still I'm not getting any results at all. Why does this happen and how can I solve it? Source blend file https drive.google.com open?id 1Ze1JBRFBvhnnY w36U2KDe7Q2zcfXsmf
0
How can I use Unity Assets made by Unity in a commercial project? I know you can't use starter and training etc.. assets made by Unity for commercial purposes, but according to this every Unity asset made by Unity is restricted for commercial use. So that means I can't use Post Processing Stack? That would be disappointing.
0
Can we measure the distance between and AR marker and camera? I'm in the middle of developing a game in Augmented Reality using Unity and ARToolkit plugin. I wanted to measure the approximate distance between the AR marker and the position of camera. Can anyone help me with a solution to this problem? Thanks in advance.
0
Timer breaks after changing scenes I am using this script below to move an animation in unity with no root motion. It simply walks across the terrain. I have timer attached also so the animation doesn't start to walk for 60 seconds. This works fine in the scene when played but when I navigate into this scene from another home scene the timer delay doesn't work as I guess it has been triggered already and has already reached the 60 second mark? I have tried using DontDestroyOnLoad but this just recreates the animation in the home scene also. I'm trying to keep the code as simple as possible and maybe add to the code below to fix it void Update () if (Time.time gt 60) transform.Translate (0, 0, Time.deltaTime)
0
How do mobile games implement time gates unhackably? Is it possible in offline games? I'm thinking about porting my game to Google Play, and it would be free to play with time gates which are skippable if you watch an ad. What are the ways of implementing an unhackable time gating? Is it possible without internet connection? If yes, how? If no, is there a way to implement it without custom backend, using Google Play's services? Or should I care about this at all? Because... It doesn't affect other players... Most of the audience couldn't do it anyway, and if the game stays small, hacks couldn't really spread. Then maybe I should just let them hack those time gates, it's a marginal revenue loss. What do you think?
0
How to get the tangent and normal of a collision? In my game, one of my objects casts a ray into a 2d space. If that ray were to hit another object, I'd like to draw a line that is perpendicular to the tangent of the ray's hit point. So when the ray hits the other object, a tangent is formed at the point of contact, and then I'd like to use the linerenderer component to draw a line that is perpendicular to that tangent. I already know how to use the linerenderer to draw lines, but I don't know how to get the tangent and normal from a collision. if (Input.GetMouseButton(0)) Vector2 mousePos Camera.main.ScreenToWorldPoint(Input.mousePosition) var direction (mousePos (Vector2)cueBall.position).normalized var hit Physics2D.Raycast(cueBall.position, direction, Mathf.Infinity, 1 lt lt LayerMask.NameToLayer("Ball")) if (hit) line1.SetPositions(cueBall.position, hit.point) This is the line from the cueball to the red ball. line2.SetPositions(hit.point, hit.normal) This is supposed to be the predicted trajectory of the red ball.
0
Add Lerp on only the Y axis I want my camera to be smooth on only the Y axis.How do I do that it? Current code public Transform target public float smoothSpeed 0.3f public float offsetX 1f public float offsetY 1f public float offsetZ 1f void FixedUpdate () Vector3 pos transform.position pos.x target.position.x pos.y target.position.y pos.z target.position.z Vector3 positionz pos.z Vector3 smoothedPosition Vector3.Lerp(transform.position, pos, smoothSpeed) transform.position smoothedPosition
0
Unity Static Camera Perspective, Walls Obscure Player Pretty simple and common problem here. The world I'm designing is fully explorable, no invisible walls or tricks. It's presented as a single seamless area, a School complex with 9 buildings, some of which have 2 or 3 floors and contain many rooms. The perspective I've chosen is simple, inspired by topdown RPGs A problem arises with walls. They obscure the player. I've tried some shaders which draw a silhouette of the player ontop but I don't like this approach, other objects and decoration remains obscured behind the wall. Some kind of dissolve effect allowing you to see through the walls would be preferable, but writing my own shaders is not my fort ... Another problem is with large buildings outside. The camera is at a fixed distance, about 14 metre's away. If the player walks behind a large building (over 10 metres tall) then the camera cuts off the top of it as it is now within the building. The only way I can think of fixing this is to adjust the distance between player and camera, but some of the buildings are so tall the zoom out looks very unusual and impractical. I suppose this is why you don't see this simplistic camera setup in large explorable games... While I've been developing games for some years now, I've only come to 3D and Unity fairly recently, so there might be a jaw droppingly simple solution which I'm not seeing. Anyway, I'd like to hear some interesting or novel approaches towards fixing these problems, besides the simple ones I've suggested. I hope that's not asking too much.
0
Calculating orbital elements from Cartesian Vectors I'm having serious troubles with getting my calculations to work. I'm calculating the orbital elements from a position vector, and a velocity vector. (I also know the distance and mass of the bodies around) The equation for angular momentum is as follows h r v The equation for eccentricity is e ((v 2 r )r (r v )v I plug in the position and velocity to get h, and I plug them into the other equation to get the eccentricity. These SHOULD be constants, and not change unless another force is put on them... yet they are not constant. In fact they change as the orbit goes around. In the diagram I have just left a trail to show the orbital path. I should be able to calculate the required information... however they rely on the constants, which are not at all constant. I reference the rigidbody's position and velocity in them, and I've entered the equations in correctly. My code for applying force between planets is as follows void CalculateForce(Transform body) float m1 rbody.mass float m2 body.GetComponent lt Rigidbody gt ().mass float distance Vector3.Distance (transform.position, body.position) float f (m1 m2) Mathf.Pow (distance, 2) Vector3 direction rbody.position body.GetComponent lt Rigidbody gt ().position rbody.AddForce ( direction.normalized f) body.GetComponent lt Rigidbody gt ().AddForce (direction.normalized f) The calculations are coming back incorrect. The eccentricity varies between 0.9 and 1.1. Anything over a 1 is not actually in orbit, and anything less is in orbit. However this remains in orbit as it travels around. Can anybody help? (I've already posted to the space stack exchange and had no luck) Thanks in advance. Update Code used to calculate eccentricity (1001f is the combined weight of both objects) Vector3 pos GetComponent lt Rigidbody2D gt ().position Vector3 vel GetComponent lt Rigidbody2D gt ().velocity Vector3 eccentricity (Mathf.Pow (vel.magnitude, 2.0f) (1001f pos.magnitude)) pos eccentricity Vector3.Dot (pos, vel) vel eccentricity 1001f
0
Unity Combine two UVs by alpha I'm currently creating a voxel game like Minecraft. To display the damage of blocks, I want to combine the alpha channel of one part of my texture map with the actual texture (like Minecraft does), how could I do that in Unity?
0
Is there a way to display navmesh agent path in Unity? I'm currently making a prototype for a game I plan to develop. As far as I did, I managed to set up the navigation mesh and my navmeshagents. I would like to display the path they are following when setDestination() is fired. I did some researches but didn't find anything about it. EDIT 1 So I instantiate an empty object with a LineRenderer and I have a line bewteen my agent and the destination. Still I've not all the points when the path has to avoid an obstacle. Furthermore, I wonder if the agent.path does reflect the real path that the agent take as I noticed that it actually follow a "smoothier" path. Here is the code so far GameObject container new GameObject() container.transform.parent agent.gameObject.transform LineRenderer ligne container.AddComponent lt LineRenderer gt () ligne.SetColors(Color.white,Color.white) ligne.SetWidth(0.1f,0.1f) Get def material ligne.gameObject.renderer.material.color Color.white ligne.gameObject.renderer.material.shader Shader.Find("Sprites Default") ligne.gameObject.AddComponent lt LineScript gt () ligne.SetVertexCount(agent.path.corners.Length 1) int i 0 foreach(Vector3 v in p.corners) ligne.SetPosition(i,v) Debug.Log("position agent" g.transform.position) Debug.Log("position corner " v) i ligne.SetPosition(p.corners.Length,agent.destination) ligne.gameObject.tag "ligne" So How can I get the real coordinates my agent is going to walk throught ?
0
Change axis to view world from above in Unity Developing a 2d game where you view the "table" from above (think of a card game being played on a table). I have a candlestick on the table, but I must have something wrong because when I run it, it thinks it's on a wall versus a table because the flame goes up to the top versus "at" the camera from above. Here's the code of that "LookAt" script public class CameraFacing MonoBehaviour public Camera cameraToLookAt void Awake() cameraToLookAt Camera.main void Update() Vector3 v cameraToLookAt.transform.position transform.position v.x v.z 0.0f transform.LookAt(cameraToLookAt.transform.position v)
0
implementing daily challenges in games I want to know how can I define daily monthly challenges in my game? Is this something can be defined locally or its need server and external services? And which servers and technologies can implements that? Is persistent connection or needed as server should send messages to clients with no request? Specifically, I use unity.
0
Put a coroutine on potentially infinite loop I have several coroutines always running. I want to put these coroutines on hold as I set the game to pause mode. Consider the content of these coroutines as follows while (timeleft gt 0) if (pause) continue ... timeleft Time.FixedDeltaTime yield return null I thought that would be okay to insert the if(pause) clause to have the coroutines to wait while pause is up. What, insted happens is that (I guess) these infinite loops make unity not responding so that I have to kill the process. Can I be right in thinking that the system does not like coroutines to be in a potential infinite loop? Or that is just okay and I have to heavily debug somewhere else?
0
How to hide Game Progress Files saved in Application.persistentDataPath in Unity Android I am developing a game that saves its state in a text file. I am writing that file in Application.persistentDataPath but my issue is that the game progress file is available to user in Data PACKAGE NAME files . How can I hide the game progress file so that user can't access the files ?
0
A pathfinding for dynamic obstacles and player made blockages? Hi I'm creating a TD in Unity 5 and need some help with my Pathfinding. I'm going to use Arons A pathfinding for my AI which enables me to use dynamic objects and update the path during run time. However in my game I want the player to be able to block the minions with special turrets which will force the minions to attack the "block tower" instead to get past to their destination. How could I accomplish something like this? Image for more clarity
0
How can I prevent seams from showing up on objects using lower mipmap levels? Disclaimer kindly right click on the images and open them separately so that they're at full size, as there are fine details which don't show up otherwise. Thank you. I made a simple Blender model, it's a cylinder with the top cap removed I've exported the UVs Then imported them into Photoshop, and painted the inner area in yellow and the outer area in red. I made sure I cover well the UV lines I then save the image and load it as texture on the model in Blender. Actually, I just reload it as the image where the UVs are exported, and change the viewport view mode to textured. When I look at the mesh up close, there's yellow everywhere, everything seems fine However, if I start zooming out, I start seeing red (literally and metaphorically) where the texture edges are And the more I zoom, the more I see it Same thing happends in Unity, though the effect seems less pronounced. Up close is fine and yellow Zoom out and you see red at the seams Now, obviously, for this simple example a workaround is to spread the yellow well outside the UV margins, and its fine from all distances. However this is an issue when you try making a complex texture that should tile seamlessly at the edges. In this situation I either make a few lines of pixels overlap (in which case it looks bad from upclose and ok from far away), or I leave them seamless and then I have those seams when seeing it from far away. So my question is, is there something I'm missing, or some extra thing I must do to have my texture look seamless from all distances?
0
How can I scroll animate up lines reading from a string to ui text? This is the reading lines code if (primaryTarget ! null) var lines primaryTarget.description.Split(' n') text.text quot Item found quot primaryTarget.description else text.text quot quot And this is the script of the description The script is attached to each interactable target(item) using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class InteractableItem MonoBehaviour public enum InteractableMode your custom enumeration Description, Action public InteractableMode interactableMode InteractableMode.Description public float distance private bool action true TextArea(1, 10) public string description quot quot public void ActionOnItem() if(interactableMode InteractableMode.Action amp amp distance lt 5f amp amp action true) action false Depending on the amount of text in the string I want to show it in the ui Text. If there is one line then just show the text or even if there are two lines. but if there is a lot of text then split the lines and scroll the lines smooth up so the first line will be disappear or pushed up and bottom lines will come up. In the screenshot you can see on the left the text that show in the ui text on the right the text of the description. The ui text can't show all the text and I don't want the text to overlap other ui's or objects so the idea is to make the text slowly smooth scrolling up.
0
Unity3d getting terrain height I am making an RTS game in unity like Total War games. As for rendering I am using Graphics draw mesh instanced method and after culling a I can easily render massive amount of soldiers on battlefield also they are animating with shader. I am not using unity gameobjects or unity physic engine(Also they are costly) as only data I am providing is Matrix4 4 to DrawInstancedIndirect method and rendering.Problem is I want to get height of terrain at specific position(to place unit on terrain) So I can pass Y value to Matrix4 4 for rendering. After seraching documentation I found that there are few ways to get height. Terrain.SampleHeight It is easy to get height with this method just need to pass vector position but costly As When there comes 10,000s of units on battlefield 10k calls for sample height kills performance. TerrainData GetHeights Can get heightvalue from it in 2d array but height I get is only for int value i.e 10,500 so there is not any option to get value sayif specific unit is at position 10.52,234.8 TerrainData.GetInterpolatedHeight I can get height for float values but I am getting inconsistant result with it. One option for me is to make flat terrain but it kills immersion. I ran out of ideas here Is there any way I can get of terrain by either terrain texture or by shader ? Sample Image EDIT GetinterpolatedCode for (int i 0 i lt position.Length i ) position is array contains info of all vectors t is terrainData q t.GetInterpolatedHeight(position i .x, position i .z) position i new Vector3(position i .x,q, position i .z) print(position i " " t.GetInterpolatedHeight(position i .x, position i .z))
0
Application.OpenURL not working I have a public void Public void patreononclick() Application.OpenURL("http www.patreon.com HubakaGs") Which supposed to open my patreon page when a button is tapped. But when i tap the button in the built application, nothing happens. I have assigned the function to the On Click() section of Button (Script). I am building the game for android patform and i use Unity 2017.1.0p4 Personal. How can i make the button to function properly? Update I changed the function to public void patreononclick() Debug.Log ("the game should open patreon") Application.OpenURL("http www.patreon.com HubakaGs") But when the button is clicked, there is no message at the console.
0
How do I achieve this glowing edge shader? I came across this example, and wanted to know how to achieve a shader that will give me similar results, i.e. the glowing edges. How do I achieve this sort of shader?
0
Algo for rotating tower towards enemy Unity I have made a grid and placed towers and moving a enemy on it. Now i want to rotate towers face towards enemy when enemy comes in the range of tower. I have a solution that whenever enemy comes to its range ( 2 grids far ) it starts do something, lets say when tower finds enemy is on left side it starts firing like that when enemy moves up down ( when it finds there is a tower on very next tile) tower starts rotating with enemy position uniti enemy's range that is 2 grids far. So its mean tower has to rotate whenever enemy comes to its range and moves up down. What would you people suggest me a optimized way or any helpful scripting function ?..thnx
0
How can i create a 2 player turn based board game on a separate android device using unity? im trying to make a 2 player turn based board game, i have already made the connection between 2 device. I used photon. They both connect but i don't know how to sync them both to the game. can any one help me? i hope my question is right.
0
Play games services leaderboard does not work all the time I am trying to login into play services. I got it working. But there were duplicate game objects created. So I added do not destroy on load and now the play services work the first time I access it. But when I go to play game scene, end the game and come back to main menu, I can not seem to load the leaderboards. public class PlayServices MonoBehaviour public static PlayServices services private void Awake() if(services ! null) Destroy(gameObject) else services this DontDestroyOnLoad(gameObject) Use this for initialization private void Start () PlayGamesClientConfiguration config new PlayGamesClientConfiguration.Builder().Build() PlayGamesPlatform.InitializeInstance(config) recommended for debugging PlayGamesPlatform.DebugLogEnabled true Activate the Google Play Games platform PlayGamesPlatform.Activate() SignIn()
0
What format should I choose? I am making models in blender to export them then in unity, and unity can import .blend formats as well as .fbx, so which one is better, is there even any difference.
0
Cant set up to get input from second analog stick So I know for a fact that the stick on my gamepad is working. The problem is I cant set it up in the Input Manager. I tried all possible Axis configurations and still getting a input values of 0. Here is a screenshot of the configuration.
0
How to get crash reports from game Unity3d I am working on a project and I am in need of to gather CrashReports, email crash log, along with allowing the user to describe how the crash happened. I cannot find anything on how to do this, anyone has any ideas? Thanks! Learning Unity User
0
Unity LLAPI Connection Problems NAT Routers? I have created a bespoke networking system using Unity's LLAPI. It works fine on the same machine, and sometimes works even to direct connect across the internet! The problem however, is that it sometimes does not want to connect to other players across the internet. It seems impossible to host the game on some ISPs, as clients cannot detect or connect to them. I assume this is related to Router NAT issues. I would like to know how I can deal with this problem, integrating with Unity's LLAPI.
0
How to make an object jump an equal height whenever it hits the ground? So, I want to make an object jump an equal height whenever it touches the ground. Something like a bouncing ball. But I can't use Physics Materials. Here are some ways that I tried Used Physics.CheckSphere isGrounded Physics.CheckSphere(rayPoint.position, grounDistance, groundLayer) if(isGrounded ) rb.AddForce(transform.up jumpForce, ForceMode.Impulse) Used Raycast bool groundHit Physics.Raycast(rayPoint.position, transform.up, rayDistance, groundLayer) if(groundHit) rb.AddForce(transform.up jumpForce, ForceMode.Impulse) In each cases, the object jumps a different amount of height each time it reaches the ground. How can I make it jump an equal height each time?
0
Quit from Unity to native iOS app I'm working on iOS application which is going to include a few unity games. And I investigate an opportunity to exit from the Unity game to the native iOS app with games list. I know that the Unity provides methods Application.Quit() and Application.Unload() I haven't try but I'm not sure that Application.Unload() is correct ways to exit from unity to the native iOS app.
0
Creating a UI health bar image for each enemy object I would like to create a small health bar on top of each enemy in my game. I know how to do this for one enemy, but I'm not completely sure how best to expand it to work for each enemy in the game. I'm guessing I should instantiate the UI health bar prefab somewhere, each time an enemy is spawned maybe? Currently, I don't even have an enemy spawner, I'm just testing by dragging enemy prefabs into the scene. I'll post the relevant scripts. public class EnemyHealthBarController MonoBehaviour private Image remainingHealthImage private EnemyHealth enemyHealth void Start() remainingHealthImage transform.Find("Remaining Health Image").gameObject.GetComponent lt Image gt () enemyHealth GameObject.FindGameObjectWithTag("Enemy").GetComponent lt EnemyHealth gt () void Update() remainingHealthImage.fillAmount enemyHealth.currentHealth enemyHealth.maxHealth if (enemyHealth.isDead) gameObject.SetActive(false) and public class ClampEnemyHealthBar MonoBehaviour private GameObject enemyHealthBar private Vector3 offset void Start() enemyHealthBar GameObject.Find("Enemy Health Bar") offset new Vector3(0f, 30f, 0f) void LateUpdate() Vector3 desiredPosition Camera.main.WorldToScreenPoint(transform.position) offset enemyHealthBar.transform.position desiredPosition Right now, I'm using GameObject.Find to set a reference to the preexisting enemy health bar in the scene. Also, I'm only finding the EnemyHealth component of one of the enemies. How might I better structure this in order to do the kind of thing I'm trying to do?
0
Animation position leftover I am fairly new to unity and I have encountered this same problem previously. I have a gun with hands and I created an animation that simulates shot movements with properties transform.position and transform.rotation. Root motion is applied and motion curves are generated for the animation.The default state animation for that object has no properties assigned to it and as much as I understand from the animation controller window, the shot animation is completed before the transition to the default state is made. The problem is that on every 3 shots 0.001 is added to the X rotation Y and Z positions are losing some small values. I tried to prolong the animations exit time but the result is the same. I checked the key values and the motion curves, the first and last ones are the same. Why is this happening and how can I fix it ?
0
Hide an image once all enemies in a zone are defeated In my game there are several buildings that a main character has to free from enemies. I put a kind of a logo above all those have to be released buildings, indicating that a certain building is not free and it has to be released. What I want to achieve is that when I kill all of the enemies near a certain building, the logo above that building has to disappear, indicating means that the building was released. I don't know how to detect this condition of "all nearby enemies defeated" in my script how can I do that, and hide the image when the condition is met?
0
Is there performance difference between OnCollisionEnter and OnTriggerEnter? Is there performance difference between OnCollisionEnter and OnTriggerEnter? I have around 12 objects all calling OnCollisionEnter when in fact OnTriggerEnter could work as well. So I wonder if the are is any difference PERFORMANCE WISE between the two
0
Best practice for play location of projectile sound effects? I am encountering an issue where I have a bullet that is destroyed on impact which is cutting off my bullet impact sound effect due to the audio source being destroyed. I like the idea of the sounds being attached to the projectile, but not sure if that is best practice. I can play the sound from an NPC script, but not sure if that will open up other issues. Is this a better approach since the NPC material is quot metal quot so I should store all the quot Metal hit quot sound effects on the NPC? ...vs. having to store all material variations of impact on the projectile?
0
How to check metadata stored in FBX files? Is there a way to check and edit metadata information stored in FBX files? I'm using 3ds Max's fbx exporter. Can this be done with it or is there any other tool for that? For example adding name, contact info, tags or anything that provides ownership of the file.
0
How to load sprite from JSON? i know how to load text, but idk how to load texture from json.. this my c public void soalbegin() filepath System.IO.Path.Combine(Application.streamingAssetsPath, "soal.json") StartCoroutine ("Json") soaldata JsonMapper.ToObject(jsonString) IEnumerator Json() if(filepath.Contains(" ")) WWW www new WWW(filepath) yield return www jsonString www.text else jsonString System.IO.File.ReadAllText(filepath) public void OnClick() soalbegin() GameObject.Find("Panel soal gambar Text").GetComponentInChildren lt Text gt ().text soaldata "data" numbersoal "soal" .ToString() this to load text from json i need variable to load sprite texture from link json and this is my json "data" "id" "1", "soal" "siapa tokoh ini", "gambar" " 1.png", "jawaban" "natsu", "shank", "goku", "gildart"
0
Rotate player to vector3 point? I want my player object rotate to face vector3 point on terrain. public Vector3 RocketPointer public Transform pointer,Player public bool rocket , button move Update is called once per frame void Update() if (button move true) Ray mouseRay Camera.main.ScreenPointToRay(Input.mousePosition) RaycastHit mousePoint if (Physics.Raycast(mouseRay, out mousePoint, 100)) RocketPointer mousePoint.point pointer.transform.position RocketPointer if (button move true amp amp Input.GetMouseButtonDown(0)) rotate player object to face rocketpointer point rocket true button move false if (button move false amp amp Input.GetMouseButtonUp(0)) rocket false public void move button() UI button button move !button move
0
How to get a Read Write Reference to Parent GameObject from a script component attached to it? I have a game object(object) with a script component(myscript) attached. I have a reference to myscript component through getComponent, and I want to change the transform of the gameObject the script is attached to. myscript.gameObject.transform (new value) The above code gives me error, Property 'UnityEngine.GameObject.transform' is read only. Is there a way to get a read write version?
0
How to Make Saving System More Secure I've been working on an saving system for my 2D RPG game, and I recently encountered an issue my saving system uses PlayerPrefs, which I heard is supposed to be used for things such as settings. I've also heard that it isn't very secure and that people can exploit it. I was wondering whether there was a way to make my saving system more secure. Here's my inventory script that also holds the save function using System.Collections using System.Collections.Generic using UnityEngine using UnityEngine.UI public class ItemInformation MonoBehaviour These are the assets for the item to change public Text nameText public Text descriptionText public Text regenText public Text amountText This is the identifier for each item public string identifier These are the variables that change with the different items public string itemName public string itemDescription public float itemRegeneration public int itemAmount Starts on awake void Awake() Function to change the object's information and such nameText.text itemName descriptionText.text itemDescription regenText.text quot HEALS quot itemRegeneration quot HP quot Loads game data LoadDataIfNeeded() Function to save game data public void SaveData() string jsonString JsonUtility.ToJson(this) PlayerPrefs.SetString(identifier, jsonString) PlayerPrefs.Save() Loads data if needed public void LoadDataIfNeeded() if (PlayerPrefs.HasKey(identifier)) string jsonInstance PlayerPrefs.GetString(identifier) JsonUtility.FromJsonOverwrite(jsonInstance, this) else SaveData() Updates on every frame void Update() Shows amount of item left amountText.text quot HAVE quot itemAmount
0
Find References In Scene of scriptable object unity asset shows incorrect results I'm trying to work out why my game is loading a large sprite atlas that I don't think it should be. The snapshot view of the profiler shows that the atlas is loaded. The references pane shows that it's loaded through a scriptable asset object. That object does indeed reference the sprites in the atlas but I don't think the object is referenced in the scene at the moment. The game boots to this scene, so the atlas should not be loaded. I've replicated this profiling on both the editor and on android, so it's not an editor only thing. When I right click on the scriptable object in the project view, while the game is running, and Find References In Scene, it shows a few game objects. None of these objects seem to reference the scriptable object. None even have monobehaviours with fields for this type of scriptable object. Some are new UI button objects, that have Canvas Renderer, Image and Button scripts only. None of which could be referencing this scriptable object. Has anyone seen this behaviour before? What's going on?
0
Unity When attaching my custom camera script camera shakes when player starts to move fast Here is my player code. Rigidbody rb Vector3 currMovement public float jumpSpeed 10 public float moveSpeed 10 public float rotSpeed 180 float distToGround public float posSmoothTime 0.5f float currPos float targetPos float posVel public float rotSmoothTime 0.5f float currRot float targetRot float rotVel void Start() rb GetComponent lt Rigidbody gt () distToGround GetComponent lt Collider gt ().bounds.extents.y bool isGrounded() return Physics.Raycast(transform.position, Vector3.down, distToGround 0.1f) void Update() Move() void Move() Rotation smoothing. targetRot Input.GetAxisRaw("Horizontal") rotSpeed Time.smoothDeltaTime if (targetRot gt 360) targetRot 360 if (targetRot lt 0) targetRot 360 currRot Mathf.SmoothDampAngle(currRot, targetRot, ref rotVel, rotSmoothTime Time.smoothDeltaTime) transform.eulerAngles new Vector3(0, currRot, 0) Movement smoothing. targetPos Input.GetAxisRaw("Vertical") moveSpeed currPos Mathf.SmoothDamp(currPos, targetPos, ref posVel, posSmoothTime Time.smoothDeltaTime) currMovement new Vector3(0, 0, currPos) currMovement transform.rotation currMovement if (isGrounded()) if (Input.GetButtonDown("Jump")) rb.velocity Vector3.up jumpSpeed rb.position currMovement Time.smoothDeltaTime I have a Rigidbody attached to my player. I think the problem is with my camera script. Here is my camera script. public Transform player Quaternion targetLook Vector3 targetMove public float smoothLook 0.5f public float smoothMove 0.5f public float distFromPlayer 5, heightFromPlayer 3 Vector3 moveVel void LateUpdate() CameraMove() void CameraMove() targetMove player.position (player.rotation new Vector3(0, heightFromPlayer, distFromPlayer)) transform.position Vector3.SmoothDamp(transform.position, targetMove, ref moveVel, smoothMove) targetLook Quaternion.LookRotation(player.position transform.position) transform.rotation Quaternion.Slerp(transform.rotation, targetLook, smoothLook) The player is not an parent of my camera. When I parent the player to my camera the shake stops. But I want a custom smooth camera movement with my custom scirpt, so I can't make the player a parent of the camera.