Quantcast
Channel: Answers by "Mortoc"
Browsing all 73 articles
Browse latest View live

Answer by Mortoc

You want to detect direction of vectors by using the dot product. if( Vector3.Dot(transform.forward, Vector3.forward) > 0.0f ) // dude is walking forward Here's a pretty clear way to learn about dot...

View Article



Answer by Mortoc

I see a couple problems: - ToList returns an object of Type List and you're attempting to assign it to a Transform[]. - ToList(Transform) should read ToList(transform) (get the instance name, not the...

View Article

Answer by Mortoc

You'll need a couple things. 1. An efficient way to detect proximity. [Physics.OverlapSphere][1] or just colliders set as triggers are good for this. This is so you can say, "Enemy is close to player,...

View Article

Answer by Mortoc

It is very easy to copy any object. Use [UnityEngine.Object.Instantiate][1] You can also procedurally move things around very easily in unity: "GameObject.transform.position = someVector3;" You can...

View Article

Answer by Mortoc

How is the font asset saved? if it's not, maybe try forcing it to import as Unicode instead of dynamic.

View Article


Answer by Mortoc

What sort of DLL are you talking about here? A .net DLL can just be dragged in to unity (assuming it doesn't have any weird requirements like System.Windows). If it's a native dll (from C++ or...

View Article

Answer by Mortoc

The *most* efficient way would be to use option 2 (GUITexture with alpha across the screen) for a single frame, setting the camera to not clear out the display buffer and then disable rendering of...

View Article

Answer by Mortoc

I'm not sure why the script wouldn't compile straight out of the box, but the compile error looks simple enough to fix. It's an interface you implement rather than a base class to extend. You can use...

View Article


Answer by Mortoc

It would look something like this. You could put this script on a GameObject and in the editor set up as many units in that array as you want. I do recommend using better names than I did: public class...

View Article


Answer by Mortoc

Sounds like z-fighting. Try using a shader that includes an offset. Simple example: Shader "No More Z Fighting/Foreground Element" { Properties { _MainTex ("Main Texure (RGBA)", 2D) = "" {} } SubShader...

View Article

Answer by Mortoc

There's a couple different things going on in From Dust, but I think the basic thing you're looking for is the [Marching Polyhedrons][1] algorithm. It's used to generate a 'shell mesh' over a point...

View Article

Answer by Mortoc

Your iteration variable has the same name as your member variable. Change the iterator (ent1) variable to a different name.

View Article

Answer by Mortoc

You can use the GUIStyle.CalcHeight function for this: http://docs.unity3d.com/Documentation/ScriptReference/GUIStyle.CalcHeight.html I'm assuming that the variable 'Answer' is your GUIStyle and...

View Article


Answer by Mortoc

You can use the normal C# System.Threading library. Here's the official MSDN tutorial: http://msdn.microsoft.com/en-us/library/aa645740(v=vs.71).aspx Just be careful not to call any Unity API functions...

View Article

Answer by Mortoc

If you keep track of your "wall" or plane as point-normal, it's really easy ([Khan academy link for the math involved][1]). The code would look something like this: Vector3 wallToObject = wall.position...

View Article


Answer by Mortoc

Sounds like a decent time to use a Coroutine. Something like this: IEnumerator RunEvent() { while(varfloat

View Article

Answer by Mortoc

You should be able to make them all the same mesh without adding tris. In your 3D modeling tool just combine all the meshes in to a single object. For prop-sized objects, that's pretty much the rule of...

View Article


Answer by Mortoc

Bug in your code. You probably want this: void Start () { GameObject newobj = new GameObject("Testing"); newobj.transform.parent = transform; // this transform, not the parent...

View Article

Answer by Mortoc

You can use http://docs.unity3d.com/Documentation/ScriptReference/TextAsset.html I recommend formatting your data in JSON or XML so that it's easier to read/maintain later on.

View Article

Answer by Mortoc

The problem you have is here: movement.x = Input.GetAxis("Horizontal") * speed; movement.z = Input.GetAxis("Vertical") * speed; You're applying movement in "world-space". If you want to move in...

View Article
Browsing all 73 articles
Browse latest View live




Latest Images