Tag Info

Hot answers tagged

3

The skydome material's shader should be set to Unlit/Texture to ignore the lighting.


3

Calculate the dot product to determine how close two vectors are. The dot product is 1 when they are exactly the same, -1 when they are exactly opposite, 0 when they are perpendicular, and decimal values when partway. So take the current direction, the target direction, then Vector3.Dot() and check if greater than .9 (or whatever threshold you decide looks ...


2

If you can have objects linked via the inspector and public/serialized fields, you should absolutely do it. It's the best way. FindObjectWithTag is for when your objects don't live in the same scene, and they don't have scripts for registering for each other. And finally, it's useful for when you need to reference a script before Awake has run, so it may not ...


2

jhocking's answer about dot product is the right answer to the question, but if you are rotating your object over time to face the right direction, inside that function you must be calculating how much you have left to rotate so that you know what direction to rotate and so that you don't rotate too far and overshoot. That means that inside that function, ...


2

You have to use StartCoroutine (probably not in the Update) in order to start its execution. Otherwise it's only a method call: void Start() { StartCoroutine(wait(5)); }


2

CharacterController controller Has a radius and height that define its space occupation. (the green cage in the image). That cage (capsule) interact with othe colliders (i.e : the terrain). If the cage its too big respect the enemy shape, you see it fluctuate, because the cage bottom touches the ground.


2

Something like this: transform.position = player.transform.position - player.transform.forward * distance; transform.LookAt(player.transform); where float distance is the distance of camera form player Consider also the solution 2 : Make camera child of player and in your player die script , you can "deatach" camera from player object transform.parent ...


2

First, it won't solve your problem, but there are a few general problems with your code. The conditions for your if branch will always be true if transform.localEulerAngles.x >= 0 and <= 360. The > 270 part is redundant since if x is less than 270, it is still possible to be >= 0. If x is 0 and lookAxisX is > 0, then adding -lookAxisX will make x < ...


2

You will want to use Texture2D.SetPixel or Texture2D.GetPixels and Texture2D.SetPixels if you want to blit sprites onto your texture. You could render your sprites to a RenderTexture. It may be faster but until Unity5 it was a Pro-only feature (which I don't have) so I haven't experimented with it yet. You can't draw individual pixels on the GPU without a ...


2

If you call coroutines this way they will be executed in order, one after another. You should fire them up with StartCoroutine(Aiming()); public IEnumerator Aiming() { yield return StartCoroutine(LoadBow()); yield return StartCoroutine(DrawBow()); aimStates = AimStates.Aim; } ...


1

You could set a boolean for example to false before yield and then after the time had passed set it back to true and then just use if statement to check if the boolean is true/false. What about efficiency, I think there's not much of a difference. From what I understand the delay from coroutine affects only something you change before and after the delay so ...


1

I'm assuming you are using two different cameras (as you probably should). If so, then the script below should work for what you want. Attach this script to the player (or any gameobject that is always active in your scene). Then be sure to assign the cameras to the script from the inspector. When you are switching cameras, particularly from the other cam ...


1

Looks to me like you should set the yaw and pitch to the current rotation's yaw and pitch whenever you enter the freemode. Should be something simple like if( enterFreemode ) { pitch = transform.eulerAngles.x; yaw = transform.eulerAngles.y; } That should ensure that whenever you enter the free camera, you have the same rotation as the original ...


1

In the Enemy script Update //assuming a as half of your vision cone angle //pseudo code foreach target { if (Vector3.Angle(target.position-trasform.position,trasform.forward) < a){ //then target is inside vision cone //next you can check vision distance ... //next you can check obstacles with a raycast ...


1

Usually when a texture is hidden in a 2D game, it's because it goes "in the back" of the screen. When you do lookAt(target), you have to remember that a Vector2 is just a vector3 with z=0 (thus, if you have z=1 for your background for example, it might go behind).


1

You can always try to use the clamp method: Ref: http://docs.unity3d.com/ScriptReference/Mathf.Clamp.html Example transform.localEulerAngles = new Vector3(Mathf.Clamp(transform.localEulerAngles.x, 0f, 90f), 0, 0); **This is just a push in the right direction (above is untested)


1

Use a LineRenderer. That's a component which draws a line in 3D space.


1

I think Fuzzy Logic answer is best suited for your question (he got my +1), but i'd like to give a naif alternative. You can setup a bunch of Unity objects like quads, text, sprites (call all that TerminalStuff) and use a separate camera (call it terminalCamera) that capture the terminalStuff (perpendiculary). Then set the render output of terminalCamera to ...



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