Quantcast
Channel: Latest Questions by alexkaskasoli
Browsing latest articles
Browse All 56 View Live

Instantiating cubes at runtime, align them

I'm making a little game demo where I'm playing around with some ideas. At the moment I'm allowing my player to build his own house in a way very similar to Minecraft. A cube prefab serves as the...

View Article



Raycast no hit when depends on input

I'm trying to cast a ray to check for collision when "W" is pressed. I figured out how it should work but I can't figure out why it's working in my first case and not in the second. 1) In this case...

View Article

Hiding objects between my character and camera, how to show them again when...

I'm using the following code to hide objects between the camera and my player: private void Update() { Debug.DrawRay(this.transform.position, (this._target.transform.position -...

View Article

Unity unexplicably freezes on a very simple procedure

I'm working on the very beginnings of a random level generator. I'm running this code: using UnityEngine; using System.Collections; public class Generator : MonoBehaviour { public GameObject rock; //...

View Article

OnCollisionEnter problems

My apologies for asking such a simple question. I have this code attached to my character (FPS character controller): void OnCollisionEnter(Collision c) { print("hello"); } I've attached a RigidBody to...

View Article


Can't get ENTER key working

I've been trying to get the Enter key working: void Update () { if (Input.GetKeyDown("enter")) { print ("enter pressed"); } } I also tried `Input.GetKeyDown(Keycode.Return)` I read the manual and other...

View Article

Can't Translate and Rotate at same time

I'm writing my own character controller that uses a rigidbody. I'm getting stuck on something weird. This is my code (variable declarations not included): void Start() { myNormal = transform.up;...

View Article

Converting this for loop to C#

I'm trying to convert this particular for loop from JS to C#. for (var t: float = 0.0; t

View Article


Screen.lockCursor mystery?

I'm using this simple code on my custom FPS character controller: void Start() { // Lock Cursor Screen.lockCursor = true; } I just want the mouse cursor to stay frozen where it is (ie: always in the...

View Article


Set RigidBody Transform y to the Characters Transform y

I'm writing a script for my character to pick up objects. I almost have it nailed down but at the moment when the character "picks" the object it stays on the floor, and just gets dragged around as the...

View Article

Creating this light effect

How can I create this light effect? I have little experience with graphics how could I create this light effect? http://misslineage2.com/media/images/pics/popup2.jpg

View Article

Swing an object back and forth

I'm trying to write a piece of code that swings an object forward and backwards. Eventually it will be for swinging a close combat weapon in an FPS. IEnumerator swing() { Vector3 orgPosition =...

View Article

Character stand straight

I've implemented a spell casting system where my character always faces where he is casting. This some times makes his y rotation change when he's casting upwards (flying enemy etc). I would like to...

View Article


Is character facing in the direction of camera?

How could I check if the character is facing in the direction of the camera or away from it?

View Article

ControllerColliderHit, two objects, takes wrong one

I'm using this code to detect the collision between my player and "Cloud" gameObject. Funnily enough this code: function OnControllerColliderHit(hit : ControllerColliderHit) { if...

View Article


How to get NetworkViewID and GameObject attached to NetworkViewID

I can't seem to find reliable information about this. I have a Network View component attached to a game object. How can I access this Game Objects NetworkViewID from code? I have tried...

View Article

Drawing a box with mouse dragged on screen

When a user clicks mouse0 I set a Vector2 orgBoxPos = Input.mousePosition; While he is holding down mouse0, I constantly update Vector2 endBoxPos = Input.mousePosition; I then try this to draw this box...

View Article


If button held 3 seconds do something

I'm trying to do a Crouch/Lay down system: 1) Press C => crouch 2) Hold C for 3 seconds => lay down The logical way to do this seemed to be to use a timer: if (Input.GetButtonDown ("Crouch")) {...

View Article

Character Controller/Motor Ground Delta

Is there a way to set a distance between the Character Controller/Motor and the ground? My ground is quite wobbly and I would like to avoid shaking the character and the camera by having the character...

View Article

Voxel Lighting

I'm working on a Voxel project for fun and learning. I've been reading up a lot on how this is done and have implemented a simple Voxel map in my project. My question is about the lighting. I've read...

View Article

UV Map, change texture color (lighter/darker)

I'm trying to figure out how I could make my own lighting system for my UV map in Unity. I have the theory nailed down (I believe) but I'm having problems on the practical side. I have a voxel...

View Article


Self-Illum Diffuse, how does it work?

I'm trying to use the built in self-illum diffuse shader. I have put a Base and an Illum texture on the object. The Illum is all black for testing purposes (also tried different shades). The Illum...

View Article


Shader that uses UV1 to map texture and UV2 to map light

I'm using a texture atlas and a light atlas to tile a mesh. I have the texture atlas working fine. I can apply textures and create a sort of tile map on my coded mesh. At the moment I'm using the...

View Article

Getting all scripts attached to a gameObject (Problem)

GameObject go = GameObject.Instantiate(bullet, transform.position, Quaternion.identity) as GameObject; Component[] c = go.GetComponents(MonoBehaviour); foreach (MonoBehaviour script in c) {...

View Article

Making a jump with Rigidbody2D character

I'm trying out the newish Unity 2D features. I'm trying to make a basic platformer. I've got left/right movement working with AddForce but I'm getting stuck on the jump. Here's what I have: if...

View Article


Simple Rigidbody2D controller (Platformer Jump)

I'm trying to make a very simple character controller script for an object with a rigidbody2D (aiming for basic 2D platformer gamelay with WASD and Space to jump). void HandleMovement() { if...

View Article

Best way to make a tilemap with the 2D features

I'm wondering what is the best way to make a tilemap with the 2D features. (Tilemap for a platformer like an old mario, not top-down like an old rpg, if that changes anything). What I've thought of so...

View Article

Getting a smooth jump with the Character Controller

I'm embarrassed to post this here, as there are already several instances of this question on the boards but sadly no proper answers. This is the Update method of my PlayerControl script: void Update()...

View Article
Browsing latest articles
Browse All 56 View Live




Latest Images