_id
int64 0
49
| text
stringlengths 71
4.19k
|
---|---|
0 |
How to Clamp rotation of a turret I'm going mad to clamp rotation of an object. I've tested using Inspector that correctly rotation range is Z 15 and Z lt 30. I've written this code but it isn't working properly ! if (rb.transform.rotation.eulerAngles.z gt 30) rb.transform.Rotate ( Vector3.forward speedTurretMovement , Space.Self) if (rb.transform.rotation.eulerAngles.z lt 15 ) rb.transform.Rotate (Vector3.forward speedTurretMovement , Space.Self) Thanks
|
0 |
How to fuse 2 sprites as they approach each other in Unity2D? Hi i seen this video by Sebastian Lague on ray marching. Link https www.youtube.com watch?v Cp5WWtMoeKg amp t 204s At 3 19 mins. I want this merging effect but for 2D sprites. Please can someone instruct me on how it can be made or the steps to make it.
|
0 |
Multiple IF statements on Update (Unity) Background I am testing out a "Pause" system for my game. I have a Game Manager script and figured as it's the GM, it's a good place to stick a Pause system. My pause works that on pressing "P" key, the timeScale is switched between 0 and 1. Due to the nature of the game, if the game is paused and then unpaused I want the timeScale to not "jump" to 1 but to gradually increase, taking half a second to reach "normal" game speed again. This aspect is NOT my issue. This is just background. My Code I have the pause detection in the Update script. I figured two if statements to check Timescale values and then to take appropriate action. (SloMoTime is a timescale that kicks in when the player wins or looses the level) My Code using UnityEngine using System.Collections using UnityEngine.UI using UnityEngine.SceneManagement public class GManager MonoBehaviour public float sloMoTime 0.2f public bool ballInPlay false .... void Update() if(Input.GetButtonDown("PauseGame") amp amp ballInPlay true) if (Time.timeScale 0) Game is already paused, so now continue... dactivate "paused" text notice paused.SetActive(false) Becauase we are speeding time up we can't use deltaTime Easy as the timescale we want is 0.5f so 1 0.5 2. So use 2. Time.timeScale Mathf.MoveTowards(Time.timeScale, 1.0f, 2f) if (Time.timeScale gt slowMoTime) Pause the game. Time.timeScale 0 Show "paused" Text notice. paused.SetActive(true) end Update. close class. Now, Can you see any major issues here? My Issue I found running my script from above, that the game did not pause. I expected every frame to load Update, then to check IF number 1, and then check If number 2 (hence in that order). then continue. I found using error logs that by swapping the If statments around that only the first if statement was ever executed. So the game would alternatively always pause but then never unpause. I additionally found with error logs that the values of TimeScale where not causing this inconsistency. What I have trouble with is understanding why this happens. Why do two completely mutually exclusive IF statements not both fire, when in the same method? FAILS Class void Update () if() works if() never works close method. A Solution BUT putting the second IF statement within an else solves this issue. WORKS Class void Update() if() works else if() works close method. Obviously this is impractical for more than a few ifs at once and I find it hard to understand why this logic works and the previous logic never did. I havn't yet dug into if this is Update or timeScale (entity rather than value) specific but Why does this happen?
|
0 |
Monster Spawner Reference Issue I have a monster spawner that spawns the quot enemy quot kid which is red, and it has a line in the script where it references the quot player quot gameobject's transform. Before I made the spawner, I had the enemies put by hand and I could reference the player object without issue. Now they're not handplaced, they are spawned from the prefab folder by the spawner. When they spawn the game gives the null reference exception error and stops. I look up to the enemies that are spawned and none of them have the player gameobject referenced. Also when I click on to the enemy prefab to reference the player object, it just doesnt allow me to. How can I resolve this issue?
|
0 |
Movement appears to be frame rate dependent, despite use of Time.deltaTime I have the following code to calculate the translation required to move a game object in Unity, which is called in LateUpdate. From what I understand, my use of Time.deltaTime should make the final translation frame rate independent (please note CollisionDetection.Move() is just performing raycasts). public IMovementModel Move(IMovementModel model) this.model model targetSpeed (model.HorizontalInput model.VerticalInput) model.Speed model.CurrentSpeed accelerateSpeed(model.CurrentSpeed, targetSpeed, model.Accel) if (model.IsJumping) model.AmountToMove new Vector3(model.AmountToMove.x, model.AmountToMove.y) else if (CollisionDetection.OnGround) model.AmountToMove new Vector3(model.AmountToMove.x, 0) model.FlipAnim flipAnimation(targetSpeed) If we're ignoring gravity, then just use the vertical input. if it's 0, then we'll just float. gravity model.IgnoreGravity ? model.VerticalInput 40f model.AmountToMove new Vector3(model.CurrentSpeed, model.AmountToMove.y gravity Time.deltaTime) model.FinalTransform CollisionDetection.Move(model.AmountToMove Time.deltaTime, model.BoxCollider.gameObject, model.IgnorePlayerLayer) Prevent the entity from moving too fast on the y axis. model.FinalTransform new Vector3(model.FinalTransform.x, Mathf.Clamp(model.FinalTransform.y, 1.0f, 1.0f), model.FinalTransform.z) return model private float accelerateSpeed(float currSpeed, float target, float accel) if (currSpeed target) return currSpeed Must currSpeed be increased or decreased to get closer to target float dir Mathf.Sign(target currSpeed) currSpeed accel Time.deltaTime dir If currSpeed has now passed Target then return Target, otherwise return currSpeed return (dir Mathf.Sign(target currSpeed)) ? currSpeed target private void OnMovementCalculated(IMovementModel model) transform.Translate(model.FinalTransform) If I lock the game's framerate to 60FPS, my objects move as expected. However, if I unlock it (Application.targetFrameRate 1 ), some objects will move at a much slower rate then I would expect when achieving 200FPS on a 144hz monitor. This only seems to happen in a standalone build, and not within the Unity editor. GIF of object movement within the editor, unlocked FPS http gfycat.com SmugAnnualFugu GIF of object movement within the standalone build, unlocked FPS http gfycat.com OldAmpleJuliabutterfly
|
0 |
Make one object rotate to face another object in 2D In my 2D project, I have an object that is sometimes above or below another object. Once the primary object comes in close proximity with the secondary object, I want the object to rotate on the z axis so that the front of the primary object is facing the secondary object. (Here, following Unity's default setup, the z axis is the axis pointing into the screen)
|
0 |
How big can a background file in Unity be? I want to start a new 2D top down project in Unity and want to figure out how to organize my background (one big file or a lot of files joined together). So how big can a background file get in Unity? The target platform is Windows.
|
0 |
Inserting into the first available inventory slot Hello my inventory system picks up one item but does not pickup any more to fill the other two slots. It is saying the whole inventory is full when it should be one slot is full. Here is my code for the inventory and this is attached to the player. public class MedInventory MonoBehaviour public bool isFull public GameObject MedkitSlot public GameObject BandageSlot public GameObject CoffeeSlot This next script is attached to the items you pickup. public class MedPickup MonoBehaviour private MedInventory medInv public GameObject itemButton private void Start() medInv GameObject.FindGameObjectWithTag( quot Player quot ).GetComponent lt MedInventory gt () itemButton.SetActive(false) void OnTriggerStay2D(Collider2D other) if (other.CompareTag( quot Player quot )) GameObject targetSlot new GameObject 0 bool validItem true switch (gameObject.tag) case quot medkit quot targetSlot medInv.MedkitSlot break case quot bandage quot targetSlot medInv.BandageSlot break case quot coffee quot targetSlot medInv.CoffeeSlot break default validItem false break if (validItem) for (int i 0 i lt targetSlot.Length i) if (!medInv.isFull i ) medInv.isFull i true itemButton.SetActive(true) Instantiate(itemButton, targetSlot i .transform, false) Destroy(gameObject) break
|
0 |
Best way to do multiple choice in Unity 2D? So I'm about to start development on a game in unity that is going to require multiple choice each choice having a some what unique function. I've thought of 2 ways of doing this but I'm unsure if there is an easier way as I've never really worked with unity. So the first way I was thinking about doing this and I think better then the second would be to make a class for each choice with all the functions that belong to that choice in there and then just calling it when its needed. However, I don't know if this will scale very well as I will have over 100 different events with their own choices... The second way I was thinking was to do it via JSON and then just code each function to parse that. So for example addmoney, dothis, dothat etc... However this seems like a lot more work then it would be worth so I'm not 100 sure... So I'm wondering what option would be better and if anyone else has any suggestions I'd love to hear!
|
0 |
Object Composition in the Unity Editor I'm trying to learn how to use Unity for my class composition, and I was wondering if you could help me. I'm trying to create a simple game where the player is trying to pop a bunch of balloons. However, any given balloon can only be popped if all of its conditions are met. Example conditions are The player color must match the balloon color The balloon must be popped in sequence (balloon A must be popped before balloon C) The balloon is only pop able during a certain time window And I'm sure you could think of more. Balloons can have 0 to many conditions associated with them, but they follow the 80 20 principle where 80 will fall into a specific category (e.g. color match only, or color and sequence only). My Initial Solution I created a "Balloon" class that contains a list of "ICondition" interfaces. When a collision occurs, the balloon loops through each condition to determine whether the balloon is pop able or not. I populate this list within a "BalloonFactory" class. For 80 scenarios I can just pass in the name of the balloon type I want. For 20 scenarios I can pass a list of conditions. This solution works, except for each new combination I need to change the factory code to include the new condition. What I'd Like to Do Instead of storing the balloon definitions in code, I'd prefer to create prefabs in Unity and use the editor to assign condition implementations to each balloon. My problem so far is that the Unity editor doesn't seem to like displaying a list of interfaces or abstract classes. Is there some way to do what I'm trying to do here? Or is there a third option which you would recommend?
|
0 |
How can I make Maya or Blender model work with mecanim? I'm working on a simple game project, where I need a stick figure. Due to being stubborn and the desire to learn a new skill, I want to make the stick figure myself! I have followed several tutorials in both Maya and blender. For Maya, I'm using the student version. I have my stick figure rigged within Maya and blender, both utilizing their respective bone tools. I can manipulate their limbs well, enough. However, I can't seem to get the models to work with Mecanim. I have the Kinect adapter for the PC and would like to be able to use it to create the animations utilizing a tool such as the Kinect v2 mocap animator. How I can get my model to work with Kinect based mocap?
|
0 |
Why doesn't Unity keep keydown states between scenes, and how can I change that? So basically, when my scene in Unity changes and I'm holding down, say, Right or Left, when the scene resets, my player (and Unity) doesn't even recognize that I'm still holding that button, until I lift my finger and put it back. Any thoughts? Sorry for any broken English or anything, I'm running off two hours of sleep.
|
0 |
Trees swaying in the wind using Tilemap I am working on a top down, tile based game (think 2D RPG). However, I would like to have trees that sway in the wind and shake a little if the player bumps into them! How should I approach this? Is it achievable with trees that are composed of tiles and part of a tilemap? Or should I exclude my trees from the tilemap and turn them into game objects instead? If I were to turn them into separate game objects, would I then manually tweak their rotation position to achieve the sway and shake, or is there some form of shader I can use?
|
0 |
Unity Help solving Uncaught Abort on HTML5 Build For some reason there is a Invoke that is triggered when a button is clicked that causes my game to crash. Any idea how I can sort this out? I have plenty other Invokes and none has given problems. I have the Enable Exceptions option set to None and game works fine inside Unity. I can give more info on the error if you can point to me to what's relevant. Thanks so much! Invoking error handler due to Uncaught abort(145) at Error at jsStackTrace (ed63bf36d25f876fa57fb81632b59202.unityweb 8 22380) at stackTrace Object.stackTrace (ed63bf36d25f876fa57fb81632b59202.unityweb 8 22551) at Object.onAbort (https v6p9d9t4.ssl.hwcdn.net html 1680115 PowerTheGrid Level3 v7.2 HTML5 Build 3998187b7e8feaa618a93b293c0e6812.js 4 11065) EDIT Here is the code generating the error public void OnClick() if (buyCoal.interactable true) trainObject.trainMovementStart() if (SceneManager.GetActiveScene().name "Level1" SceneManager.GetActiveScene().name "Level2") Invoke("coal refill", 6f) if (SceneManager.GetActiveScene().name "Level3") Invoke("coal refill", 12f) Money.UseMoney(coalcost) buyCoalAudio.Play() countdown 1 agora count up tipCoalReady 2 buyCoalButtonIndex 0 DISABLE COAL Buy Button coal stock countdown.text countdown.ToString() coaltipCounter 1 void coal refill() ThermoElectric.quota 17.5m Invoke("reactivateBuyCoalButton", 5f) void reactivateBuyCoalButton() buyCoalButtonIndex 1
|
0 |
RTS Pathfinding without collision between units Options Ever since I made my units move to a certain location a problem has popped up that of course if I try to make two or more units go to the same place they fight for the same spot. Am I just being stupid and unity already has a way around this or do I need to do something specific? I have looked into flow field path finding but no way on how to implement it. I dont want to have to use a ready made script but some pointers and other options are more than welcome.
|
0 |
Keep gravity velocity the same all the time I have 2D rigidbodies that fall to the ground, however they speed up while falling. Also, when they freeze in the air and then unfreeze, the velocity is set to 0 and they gradually start speeding up again. How can I keep the velocity constant at all times, until they hit the ground?
|
0 |
Is this Code saving performance ? It is kind of a Occlusion Culling I wanted to do Occlusion Culling on my Scene but I just get a bunch of Errors like "Couldn't load geometry..." etc. I tried to do like another way but the same thing, the Occlusion Culling just disables the Objects the Camera dont see. I tried it with OnTriggerEnter and Exit. I have 2 Areas one is on the left and one on the right, when the Player is walking in the first Area the Box Collider checks it and disables the Objects in Area2 but when Player is walking into Area2, Objects in Area1 disables and Different. Got the Script on both Areas that it disables a list of arrays as GameObjects. My Question is, does this save performance ? public GameObject deactivatingModels bool playerEntered false void OnTriggerEnter (Collider other) foreach(GameObject envis in deactivatingModels) if(other.gameObject.tag "OcclusionCuller") envis.SetActive(false) Debug.Log ("Player has entered Occuling Zone") void OnTriggerExit(Collider other) foreach(GameObject envis in deactivatingModels) if(other.gameObject.tag "OcclusionCuller") envis.SetActive(true) Debug.Log ("Player has left Occuling Zone")
|
0 |
Unity Android build fails, error Could not find com.android.tools.build gradle x.x.x Can't build for Android, error log CommandInvokationFailure Gradle build failed, And this is in it's description Could not find com.android.tools.build gradle 3.2.0.
|
0 |
Get the XZ to the right of a rotated point? I need to do this entirely with math, take a look at this picture What I'm doing is building a path finder algorithm that basically looks 30 units ahead, raycasts a few times perpendicular to the future point, finds the midpoint between the min max vectors that found the dirt road, and puts a green cube in the middle. I thought this would be rather simple, yet here I am trying to figure out how to plot the exact geometry of a rotated left right projection. I hope I explained this well enough! I'm also open to suggestions on how to do this if my approach is silly. Eventually this path will split and the algorithm has to detect the split and have the user decide which direction to go. EDIT After applying the math below (I opted to use the trig version) I go this result on my algorithm. THANK YOU!!!
|
0 |
Reading from Streaming Assets in WebGL I'm trying to set up my Unity game for WebGL, but I quickly found out that you can't access your streaming assets as you would in a standalone build. For example, I have a code snippet below of how I load in all of my game's text for localization (i.e. get english translations of all text in my UI). public void LoadLocalizedText(string fileName) localizedText new Dictionary lt string, string gt () StreamingAssetsPath will always be known to unity, regardless of hardware string filePath Path.Combine(Application.streamingAssetsPath, fileName) if (File.Exists(filePath)) string dataAsJson File.ReadAllText(filePath) deserialize text from text to a LocalizationData object LocalizationData loadedData JsonUtility.FromJson lt LocalizationData gt (dataAsJson) for(int i 0 i lt loadedData.texts.Length i ) localizedText.Add(loadedData.texts i .key, loadedData.texts i .value) else ideally would handle this more gracefully, than just throwing an error (e.g. a pop up) Debug.LogError( quot Cannot find file quot ) isReady true I've been looking at online examples, and there's a lot of obsolete examples regarding the use of unity's WWW class and php. From what I understand the UnityWebRequest is now the way to go, but I'm confused how to use it with regards to the example above. I'm also trying to figure out how to connect to my SQLite database which is also stored in streamingAssets. public SqliteHelper(string databaseFileName) if (Application.platform RuntimePlatform.WebGLPlayer) ???????? else tag databaseFileName quot t quot string dbPath Path.Combine(Application.streamingAssetsPath, databaseFileName) if (System.IO.File.Exists(dbPath)) dbConnectionString quot URI file quot dbPath else Debug.Log ( quot ERROR the file DB named quot databaseFileName quot doesn't exist anywhere quot ) Now that I can't just open an SqliteConnection, I have no idea if there's a c only solution, or if I have to learn php as suggested from tutorials such as this one. If someone could walk me through how to solve either of these problems I would greatly appreciate it.
|
0 |
Is there a way to run Unity without rendering the scene on the monitor (headless)? I am doing some machine learning and I get my environment from Unity in the form of images but the training is taking too long and it keeps me from doing anything else on my system. Is there a way to hide the simulation rendering? Any help will be highly appreciated.
|
0 |
How to get smoother transition between the surface normals rotation of player in Unity I kinda have a problem that my player is snapping onto the other surface while I wanna move a ramp up. I want to have it rotate smooth to the normals of the ramp. How can I change the code below to a smoother rotation function of the player? Code void NormalsOfGround() RAYCASTS THE NORMALS ON THE GROUND THAT THE PLAYER MOVES ALONG SURFACE Debug.DrawRay(rayCastNormal.transform.position, transform.up, Color.blue, 2.5f) Ray ray new Ray (transform.position, transform.up) RaycastHit hit if(Physics.Raycast(ray, out hit, 2.5f, GroundLayer) true) transform.rotation Quaternion.FromToRotation (transform.up, hit.normal) transform.rotation
|
0 |
Unity2d orthographic camera and z axis? I wonder if anyone can help with an explanation of the z axis and using unity with 2D with an orthographic camera. Up until now i have only been modifying the x and y values of game objects, thinking this is the correct way. i thought the Z axis didn't exist in 2D space (i.e. unity 2d with orthographic camera) but I do notice that the orthographic camera is placed at 10 on the z axis, if i change this value then the camera disappears. I sort of began to accept that. Now I cam to a point where I wanted to rotate something, and I notice that rotating eithe on the z or x axis, doesn't seem to do anything, only on the z axis, there is that z axis again ! Can anyone tell me when i should be worrying about the z axis in unity using 2D games. It seems now that it is more important than I once thought ) Thanks in advance.
|
0 |
Nav Mesh Agents are not moving along the mesh I'm fairly new to unity.I've been playing with Nav Mesh Agents lately.I have encountered this problem twice.The first time I didn't bother redoing my project all over again.But now its bothering me too much. I initially had a NavMesh baked along the road in my game.But later I had to change the layout of the roads, hence I had to rebake the Nav Mesh. But now I'm having the problem where the agents are not moving along the Nav Mesh to Reach the destination, but instead they quot try quot to move along the shortest path.As a result of this all agents gather to a point rather than moving along the track.I've shown below a picture to better illustrate my problem. They try to move along the red line instead of going along the road and then getting to the destination. I'm pretty confident that nothing's wrong with my code because it worked earlier and works well in other scenes.Is there anything I missed when re baking the Nav Mesh?Any help to get the agents to move along the road is much appreciated? Thanks in advance.
|
0 |
How can I make natural rain drops on screen? I'm trying to make rain effect drop with metaballs and trail on screen.I find a clue in shadertoy but I didn't understand how implemented https www.shadertoy.com view ltffzl unfortunately it have many math calculations and i can't use it in unity because it produces a lag.obviously I should use textures but how can I have trail effect?! my idea is using a texture and trail renderer for droping but how can I have metaballs effect? Update I could Implement Metaballs by This Article https github.com smkplus RainFX tree master but I haven't Idea about trail
|
0 |
How can I play user provided music stored on the phone inside my game? I am creating a car game. Is any way to play the music stored on the phone inside the game? I'd like the player to choose files that are already on their device and hear them played in the game. For example, in GTA Vice City game there was a folder named Music, and if we placed songs in there they would play on the car radio while we're driving around inside the game. If we want to switch the songs around, we can do so. how can I do the same in Android and iOS? I am using unity 5.2, C .
|
0 |
Unity Exposing a function to the inspector I wish to expose a script's function to the inspector, but I have no clue how to. I found something about Invoke() which was a start, but it isn't clear how to finish. My code for the class System.Serializable class MoveAction UnityEvent lt MonoBehaviour gt , IUIAnimationEvent region Move public MoveAction() to ensure only one mover coroutine can be active. IEnumerator moveRoutine null region Solution 2 using fields and not parameters Transform from Transform to float overTime public delegate void UIchain(MonoBehaviour mono) public event UIchain NEXT FUNCTION public MoveAction(Transform from, Transform to, float overTime, IUIAnimationEvent chain) this.from from this.to to this.overTime overTime public void Move(MonoBehaviour mono) if (moveRoutine ! null) mono.StopCoroutine(moveRoutine) moveRoutine Move(from, to, overTime, mono) mono.StartCoroutine(moveRoutine) Invoke(mono) IEnumerator Move(Transform from, Transform to, float overTime, MonoBehaviour mono) Vector2 original from.position float timer 0.0f while (timer lt overTime) float step Vector2.Distance(original, to.position) (Time.deltaTime overTime) from.position Vector2.MoveTowards(from.position, to.position, step) timer Time.deltaTime yield return null if(NEXT FUNCTION ! null) NEXT FUNCTION(mono) This is a lot of code, but the interesting part is the Move(MonoBehaviour mono) function. I want to expose that to the editor. How? EDIT Something like this would be preferable
|
0 |
Unity error "must have a body because it is not marked abstract, extern, or partial" I'm trying to setup a system where I pickup an object drop it into a zone, and then the object is destroyed. So far I have using UnityEngine using System.Collections using UnityEngine.UI public class TriggerZone2 MonoBehaviour public Text MyText private int score public bool CompareTag(string Player) Use this for initialization void Start () MyText.text "" Update is called once per frame void Update () MyText.text " " score void OnTriggerEnter(Collider coll) score score 1 if (other.CompareTag ("Player")) Destroy (other.gameObject) Everything works up until I try to destroy the game object. The console keeps saying Assets Scripts TriggerZone2.cs(11,21) error CS0501 TriggerZone2.CompareTag(string)' must have a body because it is not marked abstract, extern, or partial. I've looked up quite a few threads, but I'm still not sure what it wants me to do with it. How do I fix this?
|
0 |
Why is an empty Unity Iphone Build over 700 Megs? Is this Normal? So after 2 weeks of slaving over my first game I was finally done! I was entirely ecstatic....until I saw its file size. 770 Megabytes For a simple numbers game, that was way too much and I created an empty unity project as a test and that was also over 700 megs Why is an empty Iphone project this large?
|
0 |
Architecture for extremely modular game? I'm developing a modular game in Unity 5.6. Each module has very little overlap in assets with the others. I'm concerned about having a bloated repository after a few months of development, and since I'm using Bitbucket (a free account) I'm limited in my repo size, but not in my number of repos. So instead of having one huge folder for my game I'm considering having a launcher project and scene that loads builds from a folder in Assets. Each module would be its own project, and I would just drop its build into the launcher's folder. My question is, is this a reasonable approach to building a highly modular game? Hopefully I'll be continuing development for quite a while, and I want to make sure the project is as lightweight and extendable as possible. Or am I overthinking this, and should I just use one big repo?
|
0 |
To extract Grabpass image as texture2d via script We applied it to the plane object using Grabpass. I want to import the image shown in plane through script. I want to make the imported image in texture2d format. Is there a way? Below is the relevant code.
|
0 |
How to make tank track rig? On unity How to rig an unity tank track? Does it use animation or it use some another ways. Can anyone explain how to do this. thanks
|
0 |
How to remember a non consumable Unity IAP the right way I have implemented Unity 5's IAP system through Google Play. I read a few guides that mention not to store completed purchases in PlayerPrefs because it is clear text and easy to hack, but none mention the correct way to "remember" purchases. For example, when re installing an Anroid app, purchases are restored the first time the app runs by individual calls to this method defined in the Unity IAP API. public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e) my Playerpref save that I want to avoid is here. return PurchaseProcessingResult.Complete On subsuqent app runs, this method is not called again. Is there a way to query past purchases other than saving them in PlayerPrefs?
|
0 |
Delay for seconds when key is held down? Hello I am very new to Unity and am trying to make a shooting game in which when the space key is pressed down the gun charges then shoots. I want it to wait for 0.3 seconds before the gun fires off because I want an effect to happen with a particle system(I confused animation with effect in the first post). Also the problem the script has is that the bullet would not fire at all when the space is pressed. Here is the scripts I wrote void Start() StartCoroutine("Shoot",0.3f) IEnumerator Shoot() yield return new WaitForSeconds (0.3f) Bam () void Bam() transform.Translate (0, 0, 12) void Update () if (Input.GetKey (KeyCode.Space)) Shoot()
|
0 |
Changing coordinates of the object with velocity preservation In Doodle jump, if a player jumps over one side of the screen he appears on another side with preserved velocity and other physical parameters. I made two trigger colliders on the sides of the screen with OnTriggerEnter2D method. private void OnTriggerEnter2D(Collider2D collision) collision.transform.position new Vector3(collision.transform.position.x 0.95f, collision.transform.position.y, collision.transform.position.z) If I multiply collision.transform.position.x by 1f then on collision some glitching occurs. It gets stuck for a second. I believe this happens because when player is moved to the other side there is another collision detected and he is thrown back. Is there a more elegant way of handling this instead of multiplying by 0.95f? Final solution Tooltip("Controls where is the edge of the level where player is trasfered on the opposite side of the level.") SerializeField private float xAxisMovementConstraints private void DetectBoundryCross() if (transform.position.x lt ( xAxisMovementConstraints)) transform.position new Vector2(transform.position.x (xAxisMovementConstraints 2f), transform.position.y) else if (transform.position.x gt xAxisMovementConstraints) transform.position new Vector2(transform.position.x xAxisMovementConstraints 2f, transform.position.y)
|
0 |
Why are there weird texture artifacts in baked light which don't appear with realtime light? This is the comparison of the same scene, realtime light vs baked light. What's am I wrong ? EDIT In particular, also texture are low quality (see image 2). Why ?
|
0 |
Using IPAD's as controllers for a Unity game We are making a Multiplayer game using Unity. The actual game would be run from a PC projected on a screen and the players would be using their respective Ipad as a controller to play the game. I am not sure how difficult this would be to achieve inside Unity but I am assuming that all the game data inside Unity would need to be fed and retrieved from some kind of a server. How would this be possible with Unity because each Ipad would have a separate Unity build and also a separate build for the PC from where the actual game would be running.
|
0 |
How are writing shaders different in Unity's scriptable render pipeline vs the standard pipeline? So I want to start learning how to write shaders because the shadergraph seems very limited at the moment. I've done some research and it seems that I should learn the HLSL language which is used by Unity. I'm becoming confused though how this will carry over between pipelines. I read that standard pipeline shaders aren't supported in URP so I'm confused how the shader language is different in URP if they both use the HLSL language. I was wondering if someone with a better grasp on this could explain the difference between them and if the skills carry over, as most tutorials online seem to be for writing shaders in the standard pipeline. Thanks.
|
0 |
How do I use trigger colliders in Unity? I am trying to create a "Fruit Ninja" style game in Unity in VR. I have a BoxCollider on my sword set to "Trigger" and I have some "fruit" objects coming towards it. I then have this function void OnTriggerEnter(Collider other) Destroy(gameObject) Destroy(other.gameObject) I've tried applying this script to the sword and to the objects, but nothing is destroyed. In the documentation, there is also a note of "Trigger events are only sent if one of the Colliders also has a Rigidbody attached", but I've attached a Rigidbody to the objects.
|
0 |
How can I move my box collider temporarily? I'm very new to game development, I mostly program other things. I'm trying to write a basic whack a mole type of game. I've gone ahead and created a hammer with a swinging animatio in the FBX. I've also attatched a box collider to the head of the hammer. The issue is that when I play the hammer swing animation (and the hammer moves down), the box collider does not follow. I understand that this is because the animation is only for the object, but in this case it presents a problem since I need the collider to be at the hammer's lowest point once the animation gets there. What is the right way to approach this problem? I've thought of a couple solutions on my own, are any of these valid? 1) Move the Collider with the animation. I've got no clue on how to do this. 2) Store the time when I start the animation, check if enough time has ellapsed for completed animation. Then manually move collider to the contact point. Wait a few milliseconds, then move it back. I tried this, the issue with this is that it moves the entire object with the collider. void Update() if (Input.GetMouseButtonDown(0)) animator.SetTrigger("hammer") animationStartTime Time.time toAnimate true if(Time.time animationStartTime gt 0.38 amp amp toAnimate true) toAnimate false bc attatched box collider bc.transform.position new Vector3(0, 0, 0) move to target point (won't be 0,0,0 for real, just a test point) if(Time.time animationStartTime gt 0.50) bc.transform.position transform.position bcOffset reset to original position 3) Do what I did in step 2, but create a collider not attatched to a parent object so that the parent object isn't moved. I don't know how to create a collider on its own however. BoxCollider bc new BoxCollider() I then use bc.size and bc.position and set them but it does not show up on my scene view so I don't think this works. NOTES This script is attatched to hammer object. The hammer is moved with this code hPos Input.GetAxis("Mouse X") 0.7f fPos Input.GetAxis("Mouse Y") 0.7f transform.position new Vector3(fPos, transform.position.y, hPos) Edit is it possible for me to apply the animation to the collider? This would probably be the easiest way.
|
0 |
unity webgl scale page on different sizes of internet browsers on pc or phone unity only has a fixed resolution for building webgl. how can I make it changebale on users browser size change. there are some tutorials on the internet that doesn't match. there is only index.html unityloader.js gamename.json gamename.data.unityweb gamename.asm.memory.unityweb gamename.framework.unityweb gamename.asm.code.unityweb how can I make multi res webgl output happen for unity?
|
0 |
Calling method with enum parameters from buttons I have the following enum public enum WeaponType Sword, Spear, Blunt, Ranged And I have the following public methods on a component public void MyMethod1(int myparam) ... public void MyMethod2(WeaponType myparam) ... Why is it that when I try to call my methods from a Button component, I can not see the ones that use enumerations as parameters?
|
0 |
AudioSource not working. Empty Exception I'm trying to load and play an wav file that exists in my Application.dataPath but when the game gets to the line GoAudioSource.PlayOneShot(audioLoader.audioClip) It justs throws a empty exception and no sound is played. I've already checked if the path is correct and it is. I've also tried uploading this wav file to an FTP and loading it via HTTP instead of File but nothing changes. This is my full code private IEnumerator WriteResponseAudio(ResponseModel res) File.WriteAllBytes(Path.Combine(Application.dataPath, FILENAME RESPONSE), Convert.FromBase64String(res.intent.audio.content)) string path "file " Application.dataPath " " FILENAME RESPONSE WWW audioLoader new WWW(path) yield return audioLoader try GoAudioSource.PlayOneShot(audioLoader.audioClip) catch (Exception ex) Debug.LogError("Erro " ex.Message) This is the version with HTTP request private IEnumerator WriteResponseAudio(ResponseModel res) File.WriteAllBytes(Path.Combine(Application.dataPath, FILENAME RESPONSE), Convert.FromBase64String(res.intent.audio.content)) string path "http www.raphaelrosa.com response.wav" WWW audioLoader new WWW(path) yield return audioLoader try GoAudioSource.PlayOneShot(audioLoader.audioClip) catch (Exception ex) Debug.LogError("Erro " ex.Message) This is the console
|
0 |
How do I change the size and specific height values of Unity generated terrain? I'm having problems with terrain scripting while trying to do a infinite world with Unity's terrain generation. How do I change the terrain height at specific points? And how do I set the amount of terrain generated? Edit What I'm having problem with is doing that from a script, from the editor is plain easy.
|
0 |
Unity Anti Cheat solutions I'm currently working for a websites client development team and need guidance on where to go for anti cheat with unity. We have scripting, where a user can code in their own features via a editor we have made in lua, with a scripting api that allows them to interact with parts of the game via said scripting, others can exploit this with tools and execute scripts on games that didnt have said scripts, via "hacking". I'm trying to stop script execution exploit(eg scripts being executed that weren't put there by the author) and general hacks such as speedhacks, assembly injection, etc. We have tried the anti cheat toolkit but it hasn't worked well for us. In terms of execution we have the lua5.2 library in a dll, of course they can hook this library and execute anything via luas execution functions built in, statistcally linking the library would help defend againist this but that is not a option that is easily done in unity, so anyone could just hook it and execute any script lua they want. we have server side scripts(executed on server) and client local side scripts(executed on client locally), we've done our best to secure these but we're looking into more ways to help protect us, such as anti cheat. We have plans to possible invest into paid anti cheats in the future such as battleeye, easyanticheat, etc. we currently don't make a lot of capital and i have no experience making any type of anti cheat nor anti cheat in unity, where do i start and what do i do?
|
0 |
how to reference a variable in an anothere script i have a object which sets pickedup true on collision public class IDCARD MonoBehaviour private bool pickedup false Start is called before the first frame update void Start() Update is called once per frame void Update() private void OnCollisionEnter(Collision collision) print( quot k quot ) pickedup true Destroy(gameObject) now i want exit script in an another object to check if pickedup true on collison now what can i do pls give a brief explanation with a names i have given i have written your code. but i think there is some issues
|
0 |
Selecting Dictionary item based on custom classes instead of keys I am attempting to write my own path finding code for a game I'm working on that will implement a form of the A algorithm. I store my nodes of the path finding system as a class called nodes and add these to a dictionary with their position in world space as the key for the dictionary. Here's the problem. At one point I need to test the dictionary and return from it the node with the lowest "f" value. I came across the morelinq MinBy function with seemed promising, but so far have not had any luck getting it to work. Here is a stripped down version of the code using UnityEngine using System.Collections using System.Collections.Generic using System.Linq using MoreLinq public class GMove MonoBehaviour public Dictionary lt Vector3, Node gt vectorNodesOpen new Dictionary lt Vector3,Node gt () public Dictionary lt Vector3, Node gt vectorNodesClosed new Dictionary lt Vector3,Node gt () private KeyValuePair lt Vector3, Node gt currentNode new KeyValuePair lt Vector3,Node gt () private bool goal private bool findingPath void Start() goal false findingPath false public void addNodes() several nodes get added to the dictionary based on the A algorithm ending way point and beginning waypoint are stored as Vector3 public class Node public int h get set public int g get set public int f get set public Vector3 pos get set public Vector3 parentNodeVector get set void Update() if(findingPath) while (!goal) currentNode new KeyValuePair lt Vector3, Node gt (vectorNodesOpen.MinBy(x gt x.Value.f).Key, vectorNodesOpen vectorNodesOpen.MinBy(x gt x.Value.f).Key ) This is the line in which I'm attempting to get the node in the open list with the smallest f value. vectorNodesClosed.Add(vectorNodesOpen.MinBy(x gt x.Value.f).Key, vectorNodesOpen vectorNodesOpen.MinBy(x gt x.Value.f).Key ) vectorNodesOpen.Remove(vectorNodesOpen.MinBy(x gt x.Value.f).Key) remove current from open. if (currentNode.Value.pos waypointEnd) if current node end position we are done. goal true addNodes(currentNode.Value.pos, waypointEnd) Add and update nodes The line that is giving me trouble is the first line inside the while loop. I need a way to return the Dictionary item with the smallest "F" value, this would be pretty easy if it were an integer but the F value resides in the Node class. I don't have to use MoreLinq, I would be happy to do it any other way that someone can come up with. Cheers! One more note the code above is incomplete in an effort to minimize it down to only what is necessary to understand the problem more complete code can be provided if necessary.
|
0 |
Awake with ExecuteAlways sometime is not called in edit mode I'm trying to use the ExecuteAlways attribute to have a singleton both in edit and play modes. But the Awake() method sometimes is not called in the edit mode. What could be the reason for this and how to fix it? To make a short story long, I've got a not so new Unity project that I believe was developed before the age of ScriptableObjects, so they used MonoBehaviour to store game settings. And they used a kind of "Singleton" pattern that was not very stable and sometimes caused artefacts, such as creating an extra instance in edit mode which could often be saved with the scene accidentally and caused some other problems. The "Singleton" was written this way private static GlobalSettings instance null public static GlobalSettings Instance get if (instance null) instance (GlobalSettings)FindObjectOfType(typeof(GlobalSettings)) if (instance null) instance (new GameObject("GlobalSettings")).AddComponent lt GlobalSettings gt () return instance to fix it I've changed the code (and added the ExecuteAlways attribute) ExecuteAlways public class GlobalSettings MonoBehaviour private static GlobalSettings instance public static GlobalSettings Instance gt instance private void Awake() if ( instance) Destroy(this) throw new GameException( "The ' nameof(GlobalSettings) ' is a singleton!") instance this as I said Awake() is not called sometimes in edit mode and the instance remains null. Another problem is that even when Awake is called it happens after the first call of OnInspectorGUI() where the game settings are needed. Any suggestions and considerations on how to make this code work stable are welcome!
|
0 |
Getting help on collaboration with Unity especially programmers My team and I are currently creating a 3D tower defense game with Unity and are compromised of me a few animators modelers and programmers. However as I am still fairly new to Unity I have trouble figuring out ways to collaborate with them. I know not what practices or advice I could get on the front of developing this game. I was hoping someone here might have some insight as to how best to collaborate with all team members and what one might do to get a better flow of information and help or assistance when working on this project. We are all about an hour or more away from each other so we must work remotely to collaborate. Thank you in advance.
|
0 |
Share a function between two passes inside CG Shader for unity3d I'm writing a shader in CG language for Unity3d. When making transparent object you need to create two similar passes in SubShader. First to render only back faces (with Cull Front) and second to render only front faces (with Cull Back). But the code for vertex and fragment function is the same. Is it possible not to double a code and declare some functions, that would be shared between passes? I want to have something like in my code example. Shader "cool shader" Properties ... SubShader CGPROGRAM need to declare vertexOutput somewhow here float4 sharedFragFoo(vertexOutput i) COLOR How to make smth like this? .... return float4(...) ENDCG pass CGPROGRAM pragma vertex vert pragma fragment frag vertexOutput vert(vertexInput v) vertexOutput o ... return o float4 frag(vertexOutput i) COLOR return sharedFragFoo(i) call the shared between passes function ENDCG pass CGPROGRAM pragma vertex vert pragma fragment frag vertexOutput vert(vertexInput v) vertexOutput o ... return o float4 frag(vertexOutput i) COLOR return sharedFragFoo(i) call the shared between passes function ENDCG
|
0 |
2D UI Image with 1px border randomly gets different thickness I created a test image that is 60 x 60 px, which has a 1px border. I then drop that into Unity as a UI sprite image set to the same size, however the 1px border on a few sides can appear to be thicker, and this ruins the look I am going for especially when there are multiple of them. I've tested in the editor and creating builds (testing resolutions), and the same issue in all cases. It's easier to explain this with images. The left screen shot is the actual size of the image in the game view. The zoomed in image is another case where the borders change thickness, but zoomed in to make it more clearer. I've tried various settings, always the same issue. How can I get the image to appear exactly as it should with no changes to the borders?
|
0 |
Unity Scripting Runtime Version Option Missing I have been trying to open and run my couple months old project in Unity3D, and I'm getting about 500 errors. So idecided to reinstall Unity. On the tutorial for the project, it tells us to make sure the "Scripting Runtime Version" is set to 4.x equivalent. Only problem for me is I cannot see such an option in Unity5.5.4p4. How can I set .NET 4.x in Unity for good?
|
0 |
Unity3d Rigidbodies overlap even at low speeds I have an issue that I can't solve. There are many questions relating to similar issues and they come down to "change some settings" and "object is travelling too fast". My problem doesn't seem to equate to either of these. I am running through the basic tutorial for the Breakout Game and have added some of my own tweaks to the code, my issue is that even at low speed my ball overlaps with the bricks, rather than bouncing off them. I have read various related questions but nothing seems to fix this for me. Things I've done Set Project Settings Physics2d Maximum penetration For Overlap 0.0001 Set Ball RigidBody Collision detection to "Continuous Dynamic" . Set Brick RigidBody Collision Detection to "Continuous" Forced a speed limit on the ball of 25 15. Which I think is not fast at all, as most the given solutions are talking about situations arising when the offending object is travelling at much higher speeds. Bricks are standard rigidbody cubes and ball is a standard rigidbody sphere. According to this answer I have also set the rigidbody interpolation to "interpolation" for both ball and bricks. But this seems processor expensive and doesn't solve the issue. As well as set the Project Settings Physics Solver Iteration Count to 25. This does seem to have helped somewhat (ball no longer gets "stuck" inside brick wireframes, but still overlaps). Below are some screenshots of my issue and my code. The only aspect that I can't fully account for is that I've added an acceleration function so when ball is launched it accelerates over a course of several seconds to it's max speed. It's start speed is 8 (although the force applied is actually 1000 when launched, ignore that figure), and the max speed is set to 25 15. I don't know enough to say if this is somehow "breaking" rigidbody overlap detection but it seems pretty silly if so. See line 63 below Ball Source Code using UnityEngine using System.Collections public class Ball MonoBehaviour public float initialVelocity 500f public float accelerationSpeed 5f public float MaximumSpeed 15f private Rigidbody rb private bool ballInPlay false void Awake () rb gameObject.GetComponent lt Rigidbody gt () void Update () if (Input.GetButtonDown("Fire1") amp amp ballInPlay false) transform.parent null rb.isKinematic false rb.AddForce(new Vector3(initialVelocity,initialVelocity,0)) ballInPlay true void FixedUpdate () Gradually increase ball speed if (ballInPlay true amp amp rb.velocity.magnitude lt MaximumSpeed) speedUp() Debug.Log("Ball Speed is " rb.velocity.magnitude) Clamp to maximum speed if (ballInPlay true amp amp rb.velocity.magnitude gt MaximumSpeed) rb.velocity rb.velocity.normalized MaximumSpeed rb.velocity.magnitude void speedUp() This is line 63 rb.AddForce(rb.velocity.normalized accelerationSpeed,ForceMode.Acceleration) Why are the rigidbodies not detecting and preventing overlap?
|
0 |
how are semantics used when declaring a struct? I don't understand how semantics are used in shaders. While reading Unity's shader tutorials, I come across this struct v2f float worldPos TEXCOORD0 half3 worldNormal TEXCOORD1 float4 pos SV POSITION and also this struct v2f float3 worldPos TEXCOORD0 half3 tspace0 TEXCOORD1 half3 tspace1 TEXCOORD2 half3 tspace2 TEXCOORD3 float2 uv TEXCOORD4 float4 pos SV POSITION Microsoft's documentation says A semantic is a string attached to a shader input or output that conveys information about the intended use of a parameter. I know there is some kind of interpolation of data because vertices and pixels aren't one to one, thus I think semantics are used for telling the graphics library what to do about the data. But here it uses TEXCOORDX for things like world position and tangent space vectors. They don't seem to have anything to do with UV coordinates. So how are these semantics actully used?
|
0 |
Unity ECS How do I stop an entity from spawning twice? I am implementing a flight dynamics model using Unity's built in ECS package, Entities, and I keep running into one particular issue where the aircraft I'm trying to spawn gets converted into an entity twice. Essentially, I have a singleton Monobehaviour that handles setting up the aircraft entity from a GameObject Prefab. Here's the script public class GameManager MonoBehaviour private BlobAssetStore blobAssetStore public static GameManager main public GameObject planePrefab public float zBound 0.0f public float throttleMaxBound 1.0f public float alphaMaxBound 20.0f public float bankMaxBound 20.0f public float flapMaxBound 40.0f public float throttleMinBound 0.0f public float alphaMinBound 0.0f public float bankMinBound 20.0f public float flapMinBound 0.0f public State state public Properties prop Entity planeEntityPrefab EntityManager manager private void Awake() if (main ! null amp amp main ! this) Destroy(gameObject) return main this manager World.DefaultGameObjectInjectionWorld.EntityManager blobAssetStore new BlobAssetStore() GameObjectConversionSettings settings GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, blobAssetStore) planeEntityPrefab GameObjectConversionUtility.ConvertGameObjectHierarchy(planePrefab, settings) SpawnEntity() private void OnDestroy() blobAssetStore.Dispose() void SpawnEntity() Entity plane manager.Instantiate(planeEntityPrefab) prop new Properties( 16.2f, 10.9f, 2.0f, 0.0889f, slope of Cl alpha curve 0.178f, intercept of Cl alpha curve 0.1f, post stall slope of Cl alpha curve 3.2f, post stall intercept of Cl alpha curve 16.0f, alpha when Cl Clmax 0.034f, parasite drag coefficient 0.77f, induced drag efficiency coefficient 1114.0f, 119310.0f, 40.0f, revolutions per second 1.905f, 1.83f, propeller efficiency coefficient 1.32f propeller efficiency coefficient ) state new State( 0.0f, time 0.0f, ODE results 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, roll angle 4.0f, pitch angle 0.0f, throttle percentage 0.0f flap deflection ) float3 position new float3(state.q1, state.q3, state.q5) manager.SetComponentData(plane, new Translation Value position ) After a little bit of commenting here and there, I was able to determine that the following two lines are responsible for creating two separate entities, though the latter is the only one I'm capable of manipulating using the system. It's also worth mentioning that these two entities are virtually identical in the Entity Debugger, except for the fact that the first entity contains the quot prefab quot tag. planeEntityPrefab GameObjectConversionUtility.ConvertGameObjectHierarchy(planePrefab, settings) and... Entity plane manager.Instantiate(planeEntityPrefab) Is there a way to spawn this entity without both showing up in the debugger or is this unavoidable? If not, is there a way to remove the entity with the quot prefab quot tag from the world? Thanks! )
|
0 |
Unity reconstruct position from depth I am using Unity and I want to reconstruct position from depth and frustum corners in pixel shader. I am doing this In my App, I calculate view space corners of the far frustum plane and pass them to shader. (this is correct, I render spheres in world coordinates at corners and they are there). In Full screen Vertex shader Select corner based on corner index calculated from texcoord. This is also correct, I have rendered colors. This is passed to Pixel Shader as "ray" In Pixel shader float3 normal float depth DecodeDepthNormal(tex2D( CameraDepthNormalsTexture, i.uv), depth, normal) depth Linear01Depth (depth) position depth ray Reconstructed position is incorrect. The result I got for cube, that covers whole viewport is this But in reality, I should have this (or similar image with white, blue, pink for different handness) My output is somehow "blured" around the middle. Why ?
|
0 |
How to handle movements of objects in a platformer with a cylindrical map? I was wondering what would be the best approach for a game with a perspective like Resogun, where the world wraps around in a cylinder In my opinion, the easiest approach is to have a quot Center Parent quot for each moving object Offset the child object by the wanted radius Rotate the parent gt The objects will move, though this will become super limited very quickly, especially if you want to do any sort of physics. The 2nd approach is math x centerX cos(angle) radius x centerY sin(angle) radius Now i wonder if there is another way, I was thinking of another method which basically consist of changing the Forward direction of the moving objects based on their position in quot the circle quot , so basically the objects always move forward but adjust their rotation according to their position so they are always facing the right angle. My main question is that if you want to create a puzzle platformer game like Limbo for example, but in a quot cylindrical quot map like Resogun, how would you tackle it ? Thanks!
|
0 |
Art style for a character that has frequent visual changes during gameplay I'm creating a game with a bodybuilding fitness theme. The camera will almost always be focused on an inclined front view of a character who will be evolving very frequently during the game as the player 'levels up' the musculature of each part of the character such as arms, legs, chest, etc. I've been doing some research trying to figure out the most economical yet effective way to incorporate this visual mechanic of letting individual parts of a character independently increase in size and detail and have come up somewhat short, most likely due to my complete lack of experience when it comes to art (my experience is mostly in programming). I was thinking 2D would be best for this game, however maybe this one character should be in 3D? Would a low poly style fit these requirements, or should I look towards something akin to sprites or hand drawings? The games interactivity will be purely through menus so that doesn't need to be taken into account when dealing with the problem of this character. I would like this character to have some animations, of course, however I'm not sure if that fits the scope of this single question.
|
0 |
Upgrading Unity from 5.1 to 5.3.4 has broken game, specifically models made in Blender I recently decided to upgrade Unity after putting it off for some time as I have a rather sizable project started in 5.1. I knew there would be some hurdles, however, I have had very little luck in getting the game back up and running in the new version. My Blender model animations seem to be gone and many of the faces are disappearing. For example a characters arm is just missing and other similar issues across models. The warning I'm getting seems to be due, at least in part, to a shader I'm using attached to a prefab, however, when I change it to even the standard shader Im still getting the warnings and the issues persist. My question is Is there something I'm missing in the upgrade process that can make the transition easier, because right now, it would seem I need to recreate all of my Blender assets and reassign all of my materials and not be able to use some of my shaders? The process in which I upgraded was very simple. I just opened the project folder with the new version of Unity and rebuilt the project for the new version. Any help from anyone who has experience migrating projects between different versions of Unity would be appreciated.
|
0 |
How can the player select his weapon among many? I'm working on the prototype of my game, I want one of the options to have a very large amount of weapons. I have searched for tutorials, but I have only found weapons changes where the weapons have already been loaded in the scene from the inspector, like this https youtu.be Dn BUIVdAPg where they are only activated and deactivated. But I want a game like dofus where there are hundreds of weapons, I think I have a data file of the weapons and so, I can load the correct model of the weapon. How can I get the model loaded? I have read other tutorials regarding the AssetBundle, but I think that is when you need to download the models from a server for example, but I just want to load them from the same project. sorry for the bad english
|
0 |
How to organize level blocks in an Infinite runner I'm working on an Infinite Runner game. I have created many level blocks(sections) with different obstacles and pick ups for the player. They are positioned and placed manually, in such a way, to give the player a challenge. I thought that making every block a prefab and placing every obstacle and coin as a child of that prefab is going to be easier for me..because the player is going to run and these block prefabs are going to be randomly spawned in front of him and then destroyed after the player gets past them. It worked well. Then I wanted to make a change on my coins. So naturally I took the coin prefab, made the changes, and applied them hoping that the change is going to take effect on all my blocks... Well..it didn't. Then I found out that nested prefabs don't work in Unity, so now I have to reorganize everything again? How do I create organized level blocks, and then make them randomly spawn in front of the player? Is there any other option besides prefabs? Don't tell me I have to use a script for every block? Think about Banana Kong, Temple Run, Subway Surfers. The levels seem random, but it's an organized randomness with certain portions of the level repeating themselves. That's what I'm trying to do, and I don't know how to organize it...
|
0 |
How to move object on local space not object space in unity I am watching this (game dev, space parenting amp rotation) Sebastian Lague video and found that there are three spaces actually (not two) and these are world space, local space and object space. World space The static space (0,0,0) Object space related to the object space Local Space related to the parent of the object I am amazed that i didn't find the distinction between these two spaces(local and object) on official unity forms but actually it exists. My question is that why there is no Space.Local? I found that there are Space. Self and Space.World. Space.Self is refer to object space. I can move my object to object space using this void Update () transform.Translate(new Vector3(0,0,1) Time.deltaTime 2,Space.Self) And i can move my object to world space using this void Update () transform.Translate(new Vector3(0,0,1) Time.deltaTime 2,Space.World) but there is no support for local space that i could move the object to local space (means move the object related to its parent object). There is a fair distinction between Local and Object space but unity didn't consider it i guess or i am wrong.
|
0 |
How to calculate 1st, 2nd, 3rd place and draw conditions in local multiplayer game? I have a local multiplayer game with an end of round screen that pops up after each round. I'm trying to figure out the logic to calculate the 1st, 2nd, 3rd place from a maximum of 4 players. I also want draw tie conditions. It's possible for 2 or 3 players to get the same score. The score is just an int for each player. I've been struggling with this for a while... Any help appreciated, even if its just some pseudo code to point me in the right direction. Also, I'd like to avoid using Linq if possible, as I've heard it doesn't play nice with Unity. Thanks Edit Below is what I've managed to come up with for determining the draw conditions. Doesn't seem to hold up in all cases though... Surely there's a simpler approach? PlayerScore orderedScores m scores.OrderByDescending(ps gt ps.score).Take(4).ToArray() 1stPlacePlayers.Add(orderedScores 0 .playerNumber) if (orderedScores 0 .score orderedScores 1 .score) 2 player draw 1st place 1stPlacePlayers.Add(orderedScores 1 .playerNumber) if(orderedScores 0 .score orderedScores 2 .score) 3 player draw 1st place 1stPlacePlayers.Add(orderedScores 2 .playerNumber) if(orderedScores 0 .score orderedScores 3 .score) 4 player draw 1st place 1stPlacePlayers.Add(orderedScores 3 .playerNumber) else if (orderedScores 1 .score orderedScores 2 .score) 2 player draw 2nd place 2ndPlacePlayers.Add(orderedScores 2 .playerNumber) if (orderedScores 1 .score orderedScores 3 .score) 3 player draw 2nd place 2ndPlacePlayers.Add(orderedScores 3 .playerNumber) else if (orderedScores 2 .score orderedScores 3 .score) 2 player draw 3rd place 3rdPlacePlayers.Add(orderedScores 3 .playerNumber) else if (orderedScores 1 .score orderedScores 2 .score) 2 player draw 2nd place 2ndPlacePlayers.Add(orderedScores 2 .playerNumber) if (orderedScores 1 .score orderedScores 3 .score) 3 player draw 2nd place 2ndPlacePlayers.Add(orderedScores 3 .playerNumber) else if (orderedScores 2 .score orderedScores 3 .score) 2 player draw 3rd place 3rdPlacePlayers.Add(orderedScores 3 .playerNumber)
|
0 |
Unity detecting edge of mesh or end of mesh I'm trying to create procedurally generated tiles and I've reached a point where I need to figure out the boundaries of the mesh or the outer vertices of the mesh. RaycastHit hit if (Physics.Raycast(bound i .v2, Vector3.forward, out hit)) if (hit.distance gt 2) I've tried raycasting all the vertices, but still can't get the vertices of the edge. The mesh does have a collider. any help on how i would go about this is appreciated, Thanks.
|
0 |
How to load scene after a set delay? I have tried using IEnumerator and Invoke("method",delay in seconds). My first scene is just an image with my studio name on it. I have script that will load the next scene ("Main Menu") 3 seconds after the first scene is loaded. For this, I tried using IEnumerator and Invoke with 3 seconds delay before calling Application.LoadLevel. However, on the device, game is launched, unity splash screen is displayed and "Main Menu" scene appears. it looks like the image scene loads while unity splash screen is displayed and by the time unity screen is completed, the image scene has done executing. Is there any way to ensure a scene stays on screen before loading the next scene? I could add a button that player should tap to start game. But I don't want to do that.
|
0 |
How to select multiple frames from a sprite sheet in unity I have a sprite sheet and cannot figure out how to select multiple frames in unity 5.5 I am watching a tutorial and it doesn't say how to do it. Is there a button I have to press while clicking or is it having to change some settings?
|
0 |
Hierarchical "Select GameObject" Dialog or names with prefixes? I am attempting to connect a series of teleporters with entrances inside a single scene. Once the player touches a teleporter he is moved to another place. I am doing this by simply connecting two game objects as shown in the following screenshot. The particle system in the center of the upper side is used as teleporter, the red line indicates the game object where the player will be transported to. Sadly, this results in an utter mess when attempting to select a new entrance the teleporter should link to. There is no way to guess which entrance corresponds to which side and dice So the tl dr of my problem would be this The name of the object that should be selected is meaningless when isolated. It's the path to the object (or in other terms the name of some parent) that is relevant. I would see three possibilities to solve this, but sadly I haven't gotten around to find out how to do any of them. Switch the "Select GameObject" Dialog to use the same hierarchical view as used in the scene viewer. Is there a hidden option somewhere in Unity that I overlooked? Somehow prefix the names of my entrances programatically. Is there a way to include the path to a certain game object in its name? My whole approach is backwards and I am doing something in a not Unity friendly way. But what would be the "correct" way to do this?
|
0 |
Volumetric lighting not working when building and running game I have a volumetric lighting system implemented into Unity and when I am making the game and run it in the Unity editor the volumetric lighting shows up. When I build it and run it though it doesn't. I think this is caused because it has not exported the script with the volumetric lighting so I exported it again and it still didn't show. I dont know what is up. Any suggestions would be appreciated. In Unity with the thing working Unity built game
|
0 |
Coding style about collisions with geometry Let's say I'm writing 3D Pacman. I have "Dot" objects throughout my maze, that are structured as follows in the Inspector Dot (GameObject) Sphere w Collider When I run into the sphere trigger, I can trivially say "Get me your parent and check if it's a Dot" However, I hate baking in the knowledge that some spheres have parents that are Dot objects. If the trigger were on the Dot itself that problem would solve itself, as I could just call GetComponent(). What's a good programmatic style approach to finding out what logical Game Object actually owns the geometry you've collided with? I could add a Tag of "Dot" to the sphere but that's just a level of confirmation, I still would have to walk up to it's parent and check.
|
0 |
Gradle Build Error Unity 2019.1.6 I found out that unity has deprecated the internal build system and has defaulted to gradle. I've not built with the gradle build system before, and now after upgrading to unity 2019.1 full version, I can't build an android project. And, I installed the android module using unity hub, what can I do to fix this? Screenshot1 Screenshot2 Screenshot3 Screenshot4 Screenshot5 Screenshot6
|
0 |
What is the correct way to raycast on click? I am using raycast from screen point to detect if the user has clicked touched on something. The following fails 1 10 times at first I thought due to the raycast missing the subject below, but after adding in the drawline i realise that it randomly doesn't even fire layerMask declared with correct layers void FixedUpdate() if(Input.GetMouseButtonDown(0)) Debug.Log("click") Ray ray RaycastHit hit if(Physics.Raycast (ray, out hit, Mathf.Infinity, layerMask)) Debug.Log("You clicked on " hit.collider.gameObject.name,hit.collider.gameObject) If I run this in Update() function instead, it will work perfectly so FixedUpdate() seems to understandably cause the missed clicks... but i'm told I should always run the raycasts in FixedUpdate() for physics optimisation. Maybe I should split this basic action over 2 functions? A friend said i need an event handler
|
0 |
Calculating t value to use with Hermite interpolation I'm developing an FPS in Unity using Photon for networking. The Photon provided interpolation is very basic so I decided to roll out my own using the Hermite spline. It works good and is significantly better than the provided interpolation. However, I was wondering what's the correct way to choose the t value. In a perfect world, it should be incremented by deltaTime timeBetweenPositionUpdates. However, that doesn't work since even if the tickRate is set to 10 for example, sometimes the client sends it at 9.5, and then at 10.2 and so on and so forth. This means that we can't have a constant increment rate for the t value since it'll either lag behind or move too fast and we'll run out of buffered frames. What I decided to do is to send the time between frame updates as well and interpolate using that. But, this also isn't perfect by any stretch of the imagination and the receiving client will soon lag very much behind. What I'm doing now is using a multiplier on the t value such that if there is more frames in the buffer than we want to have then it'll speed the interpolation up, and if there's less than how many we want in the buffer then it'll slow the interpolation down. This works pretty well, but it's a hack I believe. Is there a better way, or a proper way to do this?
|
0 |
Collider Effeciency Question I'm creating a game where hundreds of rockets with colliders attached are shooting at a player. Should I write my script where 1 The player script reads the collision from hundreds of rocket colliders or 2 Each rocket collider updates information when colliding with the player Thanks!
|
0 |
Insert 3d text to the front face of a cube GameObject I want to add a text to a cube in Unity. I have a cube which has a 3d text as a child. I am using the below UnityScript to write on the 3d text var countdown int 200 function Update() GetComponent(TextMesh).text countdown.ToString() I am trying to write show the text to the front face(or very close) of the cube but I am failing. EDIT My difficulty is to make the text appear in the front side face of the cube, like it is written on it. Attaching the text or the script to any object is not an issue My last failed try was to use the below lines var tm gameObject.AddComponent(TextMesh) tm.text countdown.ToString() Any ideas?
|
0 |
Instantiate a new Prefab I m developing a little 3D game to improve my Unity C development. However, I am faced with a recurring error that I cannot find the solution to In fact, I always get the error Nullreferenceexception Object reference not set to an instance of an object when I want to create a new Gameobject in my scene. I wish I could spawn a bonus based on a percentage of chance when an enemy is killed. So I created a Bonus mother class and a Bonushealth daughter class. So Bonushealth inherits the Bonus methods. Here s the mother class code (Bonus) using UnityEngine public class Bonus MonoBehaviour protected int lifeTime public int LifeTime get gt lifeTime set gt lifeTime value protected void RandomDropBonus(Transform posEnemy) int chance Random.Range(1, 100) switch (chance) case int n when (n lt 100) Instantiate(Resources.Load lt GameObject gt ("bonus"), new Vector3(posEnemy.position.x, posEnemy.position.y, posEnemy.position.z), Quaternion.identity) break public void RandomBonus(Transform posEnemy) int rdn Random.Range(1, 1) Debug.Log(rdn) if(rdn 1) RandomDropBonus(posEnemy) Here's the daughter class code (BonusHealth) using UnityEngine public class BonusHealth Bonus public GameObject prefabHealth Start is called before the first frame update void Start() LifeTime 10 I call the RandomBonus() method when an enemy is killed (in the Enemy class), Here's is the code private Bonus bonus bonus.RandomBonus(this.transform) if I make Bonus bonus new Bonus() I always get this error ArgumentException The Object you want to instantiate is null. In my prefab folder is contained my bonus prefab named bonus. I added the Bonushealth script on it. I did a lot of research on the Internet but no way to find a solution Thanks in advance )
|
0 |
How i can play movie in unity by script(android platform)? my script is correct in pc platform but when i switch on android platform i have compiler error cs0246, why i can not export my apk file. how i can play movie in unity android platform by other way? public class NewBehaviourScript MonoBehaviour public MovieTexture myMovie void Start() myMovie.Play() void OnGUI() GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), myMovie)
|
0 |
A collider defined as intersection of two colliders I'm working in unity and I have the following problem Suppose you have an object that's very similar to say the intersection of say the corner of a cube and a ball, and you want a nice collider for this object. First option is to simply use the mesh collider option but this is apparently not very efficient, and if for example the sphere is very smooth, there might be a lot of polygons and that could be a problem. Second, you could just fill the object with various simple colliders. However, both of the above options seem unnecessarily complicated it would seem natural to me to somehow work with both colliders the sphere collider and the cube collider. To determine if the object is touching something, the requirement is that both the cube and sphere collider are touching something, not just one of them. I don't know how the actual collision checks work, but I would expect that say in the second option I wrote above (placing a few small colliders inside the object), a collision check sees if any of the colliders is touching a collider of some other object so there is an option for "union" type of collision check (see if any of the colliders are touching something). Similarly, I would expect there would be an option of checking whether both the colliders are touching something, but I'm not aware of it. Either way, I would appreciate ideas on how to implement a good collider for this problem, and whether there's a way to implement it by the way I described, using the "intersection" of two colliders.
|
0 |
Why are my animated objects (from Blender) always playing at the global origin in Unity? I created and animated a sledgehammer in Blender 2.67b using an armature. The sledgehammer has one animation (created using the Action Editor) called "Idle". I parented the imported sledgehammer to an empty GameObject and set the sledgehammer's position to (0, 0, 0). I then moved the parent GameObject to where I want it in the scene. When I launch the game, the animation plays but the sledgehammer child always re positions itself to be at the global origin, no matter where I place the parent GameObject. See the image below Notice how the sledgehammer's position goes from (0, 0, 0) to ( 1087, 3, 1149). The armature has a single bone and has the sledgehammer object as a child. I've spent about 4 hours looking this up on the Internet, but it seems like parenting the animated mesh to an empty GameObject worked for everyone else except me. Anyone else experience this? I've tried both .fbx and .blend files.
|
0 |
Isometric ball moving in unity 3d. Ball moving in opposite direction I am making a game in unity 3d. It is a 2.5d game which mean it is in isometric. The game is quite simple. Player drags mouse and a trajectory will be shown just like in angry bird and when player release the mouse the ball will move to the direction. However I am having issue here that once mouse is released the ball moves in exact opposite direction. I am not able to understand what the real issue is. My code is as follows For Ball public class BallScript MonoBehaviour public Rigidbody2D rbg public CircleCollider2D col public Vector3 BallPos get return transform.position void Awake() rbg GetComponent lt Rigidbody2D gt () col GetComponent lt CircleCollider2D gt () public void PushBall(Vector2 force) rbg.AddForce(force,ForceMode2D.Impulse) to enable rigidbody so we can use projectile again public void ActivateRb() rbg.isKinematic false public void DeActivateRb() rbg.velocity Vector3.zero rbg.angularVelocity 0f rbg.isKinematic true The code for my game manager is as follows public class Trajectory MonoBehaviour SerializeField int dotsNumbers SerializeField GameObject dotsParent SerializeField GameObject DotsPrefab SerializeField float dotSpacing Vector2 pos float timeStamp Transform dotsList void Start() hide trajectory in the start Hide() PrepareDots() void PrepareDots() dotsList new Transform dotsNumbers for(int i 0 i lt dotsNumbers i ) dotsList i Instantiate(DotsPrefab,null).transform dotsList i .parent dotsParent.transform public void UpdateDots(Vector3 ballPos,Vector2 forceApplied) timeStamp dotSpacing for(int i 0 i lt dotsNumbers i ) pos.x (ballPos.x forceApplied.x timeStamp) pos.y (ballPos.y forceApplied.y timeStamp) (Physics2D.gravity.magnitude timeStamp timeStamp) 2f dotsList i .position pos timeStamp dotSpacing public void Show() dotsParent.SetActive(true) public void Hide() dotsParent.SetActive(false) Here is the code for gamemanager using singleton pattern Camera cam public BallScript ball public Trajectory trajectory public static GameManagerScript Instance void Awake() if(Instance null) Instance this SerializeField float pushForce 4f bool isDragging false Vector2 startPoint Vector2 endPoint Vector2 direction Vector2 force float distance void Start() cam Camera.main ball.DeActivateRb() void Update() if(Input.GetMouseButtonDown(0)) isDragging true OnDragStart() if(Input.GetMouseButtonUp(0)) isDragging false OnDragEnd() if(isDragging) OnDrag() void OnDragStart() ball.DeActivateRb() startPoint cam.ScreenToWorldPoint(Input.mousePosition) trajectory.Show() void OnDrag() endPoint cam.ScreenToWorldPoint(Input.mousePosition) distance Vector2.Distance(startPoint,endPoint) direction (endPoint startPoint).normalized force direction distance pushForce trajectory.UpdateDots(ball.BallPos,force) void OnDragEnd() ball.ActivateRb() ball.PushBall(force) trajectory.Hide() The ball moves in exact opposite direction where I wish to send it by dragging. Is it because of the isometric issue or I am missing something?P.S have applied negative force as well as in case and have also made change in direction formula rbg.AddForce( force,ForceMode2D.Impulse) direction (startPoint endPoint).normalized
|
0 |
How to filter list of all objects in Unity project, by their type? I want to filter the list of project objects in unity, and view all objects of specific type in the project. (by type, not by name) How can I do that?
|
0 |
Handheld video playback pauses when going to the home screen Put an MP4 movie in your StreamingAssets folder and play it with Handheld.PlayFullScreenMovie("MyMovie.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput) Then, in the middle of the movie, go to the home screen and then go back to the game. The video is paused. You can't resume it because upon tapping the screen the video will disappear because of the CancelOnInput parameter (which I want to keep). So how can I make it so when the player returns to the game, the video resumes? I don't want to show video controls. I am using Unity Pro 5.4.2, running on an iPhone 7 with iOS 10.1.
|
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 |
Formatting Unity data for communication with a REST API I am pretty new to unity but I am not new to programming. I am building a Hololens application in Unity 2017.2 and it communicates with a REST api that I built. I am using Unity as a front end more or less and it manages my state. Coming from the web developement world, I have my server converting my models into JSON and I am sending that as a response. For the most part, it works well but since Unity works on an older version of C , I am having issues working with the JSON data, mainly if the data type is not a string, int, float, or double. For example, if my model contains a date data type I am having issues converting it back into a c model or even arrays are proving to be a pain. I don t want to rely on unity packages too much as most I have tried don t do what I need but I am open to any good ones if you know of any. My question is, what is the best way to send data from my API to Unity? Should I send xml or a csv instead? Or even a more C native approach? (If that makes sense)
|
0 |
How to stack sprites? I am currently working on a 2D game in Unity, I am using Animation Controllers Animators for the different slots of armor on the character. The scripts set the Animation to the player object and that seems to work out alright for the most part. However when I walk long distances without stopping it seems like the armor tends to drift away from the player object and I haven't been able to find out why. This will update the player and then update all his inventory to match his position. public void UpdateMovement() if (IsActive true) float input x Input.GetAxisRaw("Horizontal") float input y Input.GetAxisRaw("Vertical") bool playerMoved false Vector2 movement new Vector2(input x, input y) float delta Time.deltaTime if (movement ! Vector2.zero) animator.SetBool("IsWalking", true) animator.SetFloat("x", input x) animator.SetFloat("y", input y) playerMoved true else animator.SetBool("IsWalking", false) playerMoved false PlayerController.transform.position new Vector3(input x, input y, 0).normalized delta Inventory.UpdateMovement(input x, input y, delta, playerMoved, PlayerController.transform.position) This code is for each slot to update it's position. public void UpdateMovement(float x, float y, float time, bool isWalking, Vector3 pos) animator.SetBool("IsWalking", isWalking) if (isWalking true) animator.SetFloat("x", x) animator.SetFloat("y", y) animator.transform.position new Vector3(x, y, 0).normalized time animator.transform.position pos So my question is, what is the best approach for layering armor sprite animations on a player in Unity 5?
|
0 |
How to get good movement synchronization in a networked game (action shooter) I've spent the last two days trying to get good movement interpolation with Photon in Unity but I can't get anything that I'm happy with. I've tried several methods but none satisfied me. My understanding is that I better use some kind of interpolation (as opposed to extrapolation dead reckoning) because in my game the players can change direction fast. I've tried lerping between the current position and the last received authorized position, I've tried lerping between the old and the new authorized position, but nothing gives me the right amount of responsiveness smoothness. What can I do? Sample code public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) if (stream.IsWriting) do we have authority over this object? stream.SendNext(transform.position) stream.SendNext(transform.rotation) else newNetworkTime Time.time oldPosition transform.position oldNetworkPosition networkPosition networkPosition (Vector3)stream.ReceiveNext() networkRotation (Quaternion)stream.ReceiveNext() void RemoteMovement() float t 1.0f ((newNetworkTime interpolationPeriod Time.time) interpolationPeriod) transform.position Vector3.Lerp(oldPosition, networkPosition, t) transform.rotation Quaternion.Lerp(transform.rotation, networkRotation, Time.deltaTime movementSpeed)
|
0 |
How can I use one method and also switch between a coroutine and the main method? Now I'm using two methods, one as StartCoroutine and one not. What I want to do is to have just one method and when I set the StartCoroutine variable to true or false when the game is running I want it to switch between the coroutine and the main. Is there a simple way to do it with one method and not two, if not, how do I achieve this? using System.Collections using System.Collections.Generic using UnityEngine public class Grid MonoBehaviour public GameObject gridBlock public int worldWidth 10 public int worldHeight 10 public bool StartCoroutine false public float spawnSpeed 0 void Start() if (StartCoroutine) StartCoroutine(GenerateGridSC()) else GenerateGrid() private void GenerateGrid() for (int x 0 x lt worldWidth x ) for (int z 0 z lt worldHeight z ) GameObject block Instantiate(gridBlock, Vector3.zero, gridBlock.transform.rotation) as GameObject block.transform.parent transform block.transform.name "Block" block.transform.tag "Block" block.transform.localPosition new Vector3(x, 0, z) IEnumerator GenerateGridSC() for (int x 0 x lt worldWidth x ) yield return new WaitForSeconds(spawnSpeed) for (int z 0 z lt worldHeight z ) yield return new WaitForSeconds(spawnSpeed) GameObject block Instantiate(gridBlock, Vector3.zero, gridBlock.transform.rotation) as GameObject block.transform.parent transform block.transform.name "Block" block.transform.tag "Block" block.transform.localPosition new Vector3(x, 0, z)
|
0 |
Detect Mouse Enter on An oval shape image in unity I have an image that is attached to a panel and I want to detect On Pointer Enter and exit. The event is working fine but currently, it is working on the full image while I want to detect this event on an inner oval shape. Actual the remaing are of the image is transparent.
|
0 |
Unity Small holes of light seems to go through my blender mesh So, I am currently working on a low poly terrain in Blender which will be flat shaded in Unity. It all works great, however I am working on a cave for the terrain, and I seem to be getting these small odd light artifacts I have tried to highlight them with the read circles. If you look carefully, you can see the small holes. The odd thing is, the entire mesh should be completely solid. Here's a screenshot of the cave entrance in blender (which is the floor I'm looking at in Unity) All normals of the faces seems to be facing correctly, and mesh has simply been modelled by extruding edges from existing parts of the mesh, so there shouldn't actually be any actual holes. Does anyone have any experince with this kind of problem?
|
0 |
Unity Cube edges are jagged I am new to Unity. I have a basic setup following Brackeys tutorial. When in game mode, I see the red cube having jagged edges. I tried increasing the antialiasing in Unity to 8x but it did not work. I also tried turning on antialiasing in my Nvidia control panel. But the issue still persists.
|
0 |
How can I make a shader that renders only the scene's skybox? I am trying to replicate the following image There are a few ways about doing this that involve camera stacking, layers, etc. Is it possible to create a shader that will only render the skybox?
|
0 |
Rotation in animation not working I have a model of an SMG with arms exported from Blender and set to generic rig in unity import settings. I was creating an animation for this model in Unity Animation tab, it included changes in position and rotation of the individual parts like magazine and left arm and gun itself. Then when I was satisfied with how the animation worked (I saw it by pressing the play button IN THE ANIMATION TAB). My problem is that when I click play IN THE GAME TAB there is no rotation and some movement, only some parts move (but not rotate). Does anyone know what could be my problem? I am not sure what screenshots to post so tell me what you need to see and I'll add some. Thanks in advance.
|
0 |
(Unity) How to show a texture on a model at a specific Pixels Per Unit? I'd like to use flat 3D models alongside pixel art sprites, but I have no idea how to make the textures applied to these models have the same Pixels Per Units as the sprites. How can I achieve this effect in Unity? thank you
|
0 |
Error Cannot create FMOD Sound instance for resource sharedassets0.resource when splitting application binary in Unity I'm trying to publish an Unity app to the PlayStore. Since the size of the app is over the limit of 100MB, I need to split the binary. So I selected the option Split Application Binary in Unity. However, when I try to launch this application (either by downloading it on the Playstore or putting the .apk and the .obb directly on my device from my computer), I get the following errors on Android SDK monitor 01 24 11 38 52.442 E Unity(25004) Error Cannot create FMOD Sound instance for resource sharedassets0.resource, (File not found. ) 01 24 11 38 52.442 E Unity(25004) 01 24 11 38 52.442 E Unity(25004) (Filename Line 882) 01 24 11 38 52.442 E Unity(25004) Function SoundHandle Instance Instance() may only be called from main thread! 01 24 11 38 52.442 E Unity(25004) 01 24 11 38 52.442 E Unity(25004) (Filename Line 25) The application freezes at the "Made with Unity" splash screen. This is not happening when I don't use the Split Application Binary option and put the .apk directly on my device from my computer. I'm using Unity 5.4.0.
|
0 |
How can I create light shafts like Journey's in Unity? I'd like to create cartoon looking sun light shafts that look very close (or identical) to the ones in very well known and loved games like Journey and Ori How can I accomplish this?
|
0 |
How to handle large scene game in unity3d? I have a very very Big Huge scene to load and I can't load it at once. The one strategy i know is that I divide the scene into multiple scenes and load my scenes it into async manner as my character controller move. I am moving my character controller and accordingly loading (its near)scenes by matching its position. But it is not smooth. . . How do I load big scene smoothly? what will be the strategy? Is this right strategy which I am doing or there is any other feasible and easy to use solution available.?
|
0 |
Hide back button bar of android mobile while playing game I just want to hide back button bar of android mobile while playing the game. I tried to make it close by pressing back button,it getting close but its always visible. please help..
|
0 |
How to disable spring joint in unity 3d How can I disable Spring joint in unity 3d, since disabling feature only available in 2d mode, I am not able to find any way to disable it via script
|
0 |
Wrong contineous rotation to car In my 2d game, I want to rotate car face based on collision detected. But at present after 3 to 4 collision its doing continuous rotation only rather than moving straight after collision. Here is my straight movement related code myRigidbody.MovePosition (transform.position transform.up Time.deltaTime GameManager.Instance.VehicleFreeMovingSpeed) For better collision purpose, I have used Rigidbody position change approach. Here is my collision time code public void OnCollisionEnter2D (Collision2D other) if (other.gameObject.CompareTag (GameConstants.TAG BOUNDARY)) ContactPoint2D contact contact other.contacts 0 Vector3 reflectedVelocity Vector3.Reflect (transform.up, contact.normal) direction reflectedVelocity if (direction ! Vector3.zero amp amp pathGenerator.positionList.Count lt 0) float angle Mathf.Atan2 (direction.y, direction.x) Mathf.Rad2Deg Quaternion targetRot Quaternion.AngleAxis (angle 90f, Vector3.forward) transform.rotation Quaternion.Slerp (transform.rotation, targetRot, 0.1f) if (Quaternion.Angle (transform.rotation, targetRot) lt 5f) transform.rotation targetRot direction Vector3.zero Rotation get applied within other code so that car was changing its face correctly and that method not affecting here that I have checked by placing debug statement. Share you side thought for this.
|
0 |
Unity 2D Bullet AddForce does not work I got the following code public ParticleSystem PS public GameObject origin public float thrust 1.0f public GameObject bullet private GameObject bullet Use this for initialization void Start () Update is called once per frame void Update () if (Input.GetMouseButtonDown(0)) Debug.Log("Pressed left click.") PS.Play() bullet Instantiate(bullet, origin.transform.position, origin.transform.rotation) bullet.GetComponent lt Rigidbody2D gt ().AddForce(origin.transform.forward thrust) Where everything is working except the AddForce, the bullet is just dropping out of my weapon. I've made some research and my script seems to be correct. The bullet has attached a circle collider and a rigidbody2D. Update This did not change anything bullet.GetComponent lt Rigidbody2D gt ().AddForce(origin.transform.forward thrust, ForceMode2D.Impulse) And this neither bullet.GetComponent lt Rigidbody2D gt ().velocity origin.transform.forward thrust It's weird, because all of these should work actually.
|
0 |
My gameObject does not move, when it returns to its original scene I have a map where I have a 2d Ship as gameObject, which can be dragged with the finger to travel between islands and do the corresponding activities, when the player finishes playing on the island he returns to the map where the ship is, but when you try to drag it, you can not do it anymore. for the change of scene use collisions, as shown in the code. public string name public void OnTriggerEnter2D (Collider2D other) if (other.gameObject.tag "Player") SceneManager.LoadScene(name) Does anyone know the cause of this error? The drag code public float moveSpeed 5f private Vector3 mousePosition private Rigidbody2D rigidbody private void Awake () rigidbody GetComponent lt Rigidbody2D gt () private void Update () if (Input.GetMouseButton (0)) mousePosition Camera.main.ScreenToWorldPoint (Input.mousePosition) mousePosition.z transform.position.z Vector3 targetPosition Vector3.MoveTowards (transform.position, mousePosition, moveSpeed Time.deltaTime) rigidbody.MovePosition (targetPosition)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.