Hot answers tagged

15

When you start a coroutine by providing the method name as a string, then the Unity engine uses reflection to find the method at runtime, which doesn't care about the visibility of methods. This is not unusual for Unity. You might have noticed that methods like Start and Update are declared private, yet the Unity engine invokes them from outside the class. ...


10

The collision event represents a physics overlap that causes a collision resolution, altering the behaviour of one or both objects involved to make them bounce apart rather than pass through one another. Collision resolution can only happen when one of the bodies involved is a dynamic Rigidbody. So this isn't a limitation of the collision event, this is ...


6

The answer from Philipp is correct; I'd like to extend it slightly by addressing directly your statement: somehow I’m still able to call it ... how can that be if I marked it as private? The question indicates an important but subtle misunderstanding of what "private" applies to. "Private" does NOT mean "cannot be called from outside". Consider: class ...


3

Imagine you want a dent in a car or want to collide two cars into eachother. How will you determine impact/hit force ? Trigger doesn't return these functionalities


3

Code vs. content Game level layout is typically stored separately from your codebase. Why? Because as you've discovered, the cost of change for code is higher than the cost of change for say, a text file. In your simple case, I would opt for something like what Angband does to describe its vaults: %%%%%% %%%..##..%%% %%....####.......


2

This might not be the most elegant solution but it's certainly an effective one: What I have done in the past when using PUN for this is to use the PhotonNetwork.Instantiate() method for player instantiation. What you to avoid issues with multiple audio listeners and cameras is to write a NetworkPlayerManager script and add it to the player prefab. In ...


2

Perhaps you would like something akin to portal: The cubes you can pick up have collision responses to everything to play scraping noises etc. However the cubes only disappear when they pass through the blue light wall trigger volumes.


2

You're using the wrong namespace. Instead of using UnityEngine.UIElements; do using UnityEngine.UI; Everything else should already work when you change that.


2

What you're finding here is that drawing the line based on your height above/below the boundary gives inconsistent results: in places where the height changes quickly (steep slopes), the outline ends up being very narrow, or even disappearing at some zooms/camera angles. But in places where the height changes gradually, the outline gets thicker, because the ...


1

I basically combined Thomas Mathieson's answer combined with DMGregory's response to successfully add two players. I used if (photonView.IsMine) and within it I placed DMGregory's suggestion to instantiate the player objects such as camera and audio listener locally.An empty player object is spawned in through Photon and within that empty player object is ...


1

You've done a few things here that are making this appear more confusing than it needs to. First: your tiles are all children of a parent object - which can be good for scene organization - but it means you're not comparing apples to apples when you look at the transform values (which show you the localPosition, localEulerAngles, and localScale properties): ...


1

Found it. Somehow "monoscopic" was checked in the OVRManager No idea how that happened. Found it by looking through git diffs. Unchecking it fixed it. Of course that brings up the question, what is that setting for if it messes up the rendering? I get it means you'd no longer get stereo 3D but I'd still expect lines to render straight!??!?


1

To solve this particular problem, I would store a reference to the objects in a list, instead of setting a variable. In this case, I am using a HashSet, because it is faster than using a list, can only contain each entry once and we do not want to access the objects inside. private HashSet<GameObject> touchingObjects = new HashSet<GameObject>(); ...


1

You can use the class PlayerPrefs to store persistent data on the user's device. In order to decide whether or not to play the tutorial, find out if the player already completed the tutorial with if (PlayerPrefs.GetInt("Tutorial_Completed") == 1) { After the player completed the tutorial, set the variable with: PlayerPrefs.SetInt("Tutorial_Completed", 1);...


1

This would be simply: Vector2 endPoint = startPoint + direction.normalized * magnitude; Though you can omit the .normalized if you can guarantee your input direction is a unit vector already (ie. it is exactly 1 unit in length) You can also do this with the Ray type, if you find that clearer: Ray ray = new Ray(startPoint, direction); Vector2 endPoint = ...


1

This is simple vector math. return startPoint + direction.normalized * magnitude; If the direction is already normalized (it has a magnitude of 1.0), you can of course omit the .normalized.


1

I think the conversion to HSL and back is wasteful if you have no intention of modifying H or S, only the L. ;) So instead I've used a simpler trick below to keep the chromaticity while flipping dark to light and vice versa. I've used a simple & cheap parallax offset that's built into Unity to make use of the heightmap. You can also implement parallax ...


1

Check out this example of a system which has entities spawning more entities from Unity Technologies. This comment explains the problem: Systems can schedule work to run on worker threads. However, creating and removing Entities can only be done on the main thread to prevent race conditions. In other words, the EntityManager isn't thread-safe. So you ...


1

Well, the source of this issue changes from issue to issue. So if this doesn't solve your issue, be sure to read further down below. In my case it was due to changing the default install path for new applications. I changed the default install path to my HDD, so I don't have to manually change every new application's install path from my SSD to my HDD. ...


1

In the time since this question was first asked, the UnityScript and Boo options in Unity have been deprecated, and are no longer available in current Unity versions. (This is one reason why questions about the supported features of a particular software package aren't a great fit for the Q&A format we use here - old information can fossilize. Your ...


1

Unity scripts use C#. There are courses available to learn C# on nearly every major code learning platform, including code academy.


1

speed = startSpeed + (int)(trackedDistance / 500) * speedIncrement; Now your new question is, "how to track distance of player", Since its endless runner game: trackedDistance += speed * Time.deltaTime Ball.speed = speed; Your welcome.


1

Maybe you had messed up using collab at the first time. Collab is really simillar to git. Initiallize, update diff, merge conflicts... You'll get along to it. I suggest you to reset the collab, as it have been a long time from last work. This article should help. Also, take a look at the manual of Unity Collaborate.


Only top voted, non community-wiki answers of a minimum length are eligible