Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 18 May 2003
Offline Last Active Today, 08:01 AM

Topics I've Started

Mass Effect like camera system in unity3d

17 June 2015 - 09:37 AM

Im trying to implement a simple TPS prototype (Im bored), but the default TPS camera system is not the behaviour I want. My idea is to emulate the Mass Effect system: camera free look controlled by mouse movement, and the character moves in the direction the camera is pointing at. The default system keeps camera and player looking in the same directio, and they are rotated together. Is there some tutorial describing the first method or somebody has experience in this topic?

using an image as background for UI element

12 June 2015 - 09:50 AM

Im trying to create a sort of dialog window, which should have an image as background. I have tried using GUIContent, but cant make it work:

public Texture2D backg;

void OnGUI() {
		if (render) {
			GUIStyle style = new GUIStyle();
			GUIContent bg = new GUIContent();

			style.alignment = TextAnchor.UpperLeft;
			style.normal.textColor = Color.white;
			style.fontSize = 14;
			style.fontStyle = FontStyle.Bold;

			bg.image = backg;
			bg.text = NPCline;
			GUI.BeginGroup(new Rect(2, Screen.height-300, Screen.width-2, Screen.height-2), bg, style);			
			var i = 0;
			foreach (var line in choices) {
				if (GUI.Button(new Rect(10,60+i*40,Screen.width-30,30),line, style))

Also tried adding a Box, but it creates its own background image. How can I implement this?


show/hide window in Unity3d

01 June 2015 - 02:01 PM

Im working to implement my RPG conversation system, which in previous projects (other engines) I managed with a whole game state. In Unity3d Im still trying to figure how how to handle it, but I decided to start witha simple box to display questions and choices. The problem is that GUI.Box is not displaying anything, using this code:

public class Dialog : MonoBehaviour {

	private static bool render = false;

	public static void ShowDialog(bool toggle){
		render = toggle;

	void OnGui() {
		if (render) {
			GUI.Box(new Rect(2, Screen.height-300, Screen.width-2, Screen.height-2), "Dialog");

The code that must show the box is this:

if (Input.GetKey (KeyCode.I))
	Dialog.ShowDialog (true);

Can somebody see whats wrong here?

consuming input event in Unity UI

18 May 2015 - 09:57 AM

In my project I have a text scrolling area in the corner of the screen, it responds to mouse wheel by scrolling the contents, as expected. The problem is that Im also using mouse wheel to zoom camera. I need some way to consume or ignore the mouse wheel event if it is used by the scrolling area, how can I do this?


Weird problem with prefab position and rotation

14 May 2015 - 07:54 AM

Im facing a weird problem when trying to set an instantiated GameObject position and rotation: its locked to (0,0,0). The object is instantiated from a prefab containing only the skeleton and an animator component. I have to use the following code to instantiate it:

GameObject playerPrefab = Resources.Load("Characters/test") as GameObject;
player = Instantiate (playerPrefab) as GameObject;

If I use player = Instantiate (playerPrefab, Vector3.zero, Quaternion.identity) as GameObject; the GameObject is locked at (0,0,0) and it cant be moved to any location, not by navmesh agent, or by directly setting transform.position.

If the first method works, whats the problem? Well, the problem is that I need to manually correct the rotation. The prefab automatically gets a (-90,0,0) rotation when I add the skeleton, which lays the character horizontally when I add the rest of the meshes. No matter how I instantiate the object, I cant rotate it. I have tried setting it with player.transform.rotation = Quaternion.identity; and also with player.transform.localRotation = Quaternion.identity; none of them works. Also trying setting the rotaiton in the prefab, but again, the mesh position gets locked at (0,0,0).

Does somebody has an idea about whats happening here?