Hot answers tagged

3

Just rounding the coordinates alone won't work. You need to figure out which block the ray collided with (the coordinates), and then which face of the block, the ray intersected. From there, you can get the surface normal of that block face. Using that normal vector, you can then compute the next integer coordinate of where the block should be placed. ...


3

It looks to me like the problem is just a typo here in your node type: public int fCost { get { return gCost = hCost; } } This should be a +, not an = This typo would result in your heuristic cost h alone being used when comparing items in the heap, so the algorithm would prefer nodes close to the target even if they have a larger ...


2

Turns out there's EditorSceneManager.LoadSceneInPlayMode which does exactly what I'm looking for! Awesome. I had asked on the Unity Forum and found the answer there


2

Unfortunately, the only ways to load scenes are the two options you already mentioned. However, just because it’s in the list of scenes, doesn’t mean it needs to end up in the built game. There are two options here. The first option is to manually uncheck the checkboxes in the build settings next to all of the scenes that you don’t want to include whenever ...


2

I'd like to provide an updated version of @colourmath's solution for single pass stereo since unity has changed since then and you can use unity_StereoEyeIndex to your advantage. And since this thread is the easiest thing to find when searching for VR world position in post effect shader, I figured it would be good to help anyone searching for a solution. I ...


2

Simpler version, involve GC alloc on Animator.parameters, not cool for repeated call. public static bool HasParameter( string paramName, Animator animator ) { foreach( AnimatorControllerParameter param in animator.parameters ) { if( param.name == paramName ) return true; } return false; } // Usage sample public void ...


2

The documentation of an API is generally a good place to go to if you want to find out the list of functions, types, et cetera in that API. Unity's documentation for MonoBehavior can be found here. It includes a complete list of methods and members for MonoBehavior, which can be clicked on to get more details. If the documentation alone is insufficient for ...


1

It looks as though you're trying to fire a ray with the 3D physics engine PhysX, represented by the Physics class, and expecting it to interact with a collider managed by the 2D physics engine Box2D, represented by the Physics2D class. These are two completely separate universes that know nothing about and cannot interact with one another. (As a hint, look ...


1

Quick Edit Unity Plugin Yes, you can. You have to write your own custom script to do this, or download one (such as the plugin linked above). However, usually someone would want to do this to modify models at runtime. Odds are you will be better off building your models in a way that works for unity. But yes, via scripting you can tweak any asset you want....


1

So you already have added a property for "quantity" on your objects. This is a good start. There are a lot of approaches to this but the most straightforward approach is to use an "InventoryManager" class. So rather than directly adding items to your inventory, they would pass through the InventoryManager. This class simply scans your inventory contents to ...


1

you can simply search for unity monobehavior callbacks. you can find the, in link below: https://docs.unity3d.com/ScriptReference/MonoBehaviour.html


1

It depends on the complexity of your character. Enumerations are fine for simpler characters, but it can become very problematic when character's abilities get expanded. Virtouso's answer is good, but I'd just like to add how I go about doing state machines a lot of the time. You can create a base class along these lines: public abstract class StateBase&...


1

You are trying to get scene information before loading the scene try this it worked for me. [Test] public void Test_loadScene() { SceneManager.LoadScene(0); Scene scen_1 = SceneManager.GetSceneByBuildIndex(0); SceneManager.LoadScene(1); Scene scen_2 = SceneManager.GetSceneByBuildIndex(...


1

Hey there I see you are a new contributor. First off let me say that you can paste code directly in your question and that is desired. Secondly Have you tried loading both scenes before performing the test with : SceneManager.LoadScene("scene_name", LoadSceneMode.Additive);


1

for working with state pattern, first thing that comes to mind is enum and state. most problem is switch is not OO and most of the time its better to not to use switch-case. and you dont have much freedom to extend. its implemented like below: you can fill cases with any logic you want and you only have to change state variable to change running state. ...


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