unityscript

2D basic movement UNITY

ぐ巨炮叔叔 提交于 2019-12-02 13:14:19
Currently my character works perfectly on the keyboard, but when I convert your movements to touch, through 3 UI Buttons (i tried UI image too, but success) i'm not succeeding It basically goes to the right, left, and jumps. How should do to make it follow these instructions: When the user presses directional, the character does not stop walking until the user user releases the button, and when you press the jump player jump. This is the script I use to move through the keyboard! using UnityEngine; using System.Collections; public class Player : MonoBehaviour { public float velocity; public

Unity With C# script : Class Data Type Passing Value From Class With Data Twice Weird

你说的曾经没有我的故事 提交于 2019-12-02 11:39:19
问题 I got a simple Question and weird from passing value to data type class variable. the code like below : void AddItem(int ID) { for (int i = 0; i < database.items.Count; i++) { if(database.items[i].itemID == ID) { itemxs = new item (database.items [i].itemName, database.items [i].itemID, database.items [i].itemDesc, database.items [i].harvest, database.items [i].itemTime, database.items [i].stdprice, database.items [i].hightprice, database.items [i].itemStock, database.items [i].Lvlunlock,

OnTriggerEnter not working

无人久伴 提交于 2019-12-02 11:09:07
问题 public var enemy:GameObject; enemy = GameObject.FindGameObjectWithTag("enemy"); function OnTriggerEnter(other:Collider) { if(other.gameObject.tag == "enemy") { Debug.Log("Dead"); Destroy(gameObject); } } This script is attached to a prefab arrow that gets instantiated. The enemy has a circle collider and the arrow has a box collider. The arrow has on IsTrigger checked. What have I done wrong? Both gameobjects have a rigidbobdy2D attached. 回答1: If you use the 2D physics engine, you need to use

Collision Detection In Unity3D

旧街凉风 提交于 2019-12-02 09:46:05
I am working on 3D fighting game.I have two character with their animation.I have applied character controller and character controller script which i have customized. I have two button one to move farword and one to move backword..And four button to play different animation just like make a punch, hit a leg etc. Upto that its work perfactly fine. Now I have use capsule object with their capsule collider as a child of different bones. Like i have place one capsule object with their collider the child of left hand bone.SO where the bone move that object will move.. I have also place a capusle

Unity 3D - Limit Camera Rotation

大兔子大兔子 提交于 2019-12-02 09:25:56
I have found several awnsers to this question online, and I have tried all of them, but they either break my camera, or just overall don't work. Here is my script: using UnityEngine; using System.Collections; public class fp : MonoBehaviour { public float speedH = 2.0f; public float speedV = 2.0f; private float yaw = 0.0f; private float pitch = 0.0f; void Update() { yaw += speedH * Input.GetAxis("Mouse X"); pitch -= speedV * Input.GetAxis("Mouse Y"); transform.eulerAngles = new Vector3(pitch, yaw, 0.0f); } } As far as I know, there is 3 solutions to this problem, but I don't know how to

OnTriggerEnter not working

和自甴很熟 提交于 2019-12-02 05:20:31
public var enemy:GameObject; enemy = GameObject.FindGameObjectWithTag("enemy"); function OnTriggerEnter(other:Collider) { if(other.gameObject.tag == "enemy") { Debug.Log("Dead"); Destroy(gameObject); } } This script is attached to a prefab arrow that gets instantiated. The enemy has a circle collider and the arrow has a box collider. The arrow has on IsTrigger checked. What have I done wrong? Both gameobjects have a rigidbobdy2D attached. If you use the 2D physics engine, you need to use the 2D functions: function OnTriggerEnter2D(other: Collider2D) { if(other.tag == "enemy") { Debug.Log("Dead

UnityScript “generic functions” in Unity 5

喜欢而已 提交于 2019-12-02 04:46:23
问题 While following through the Unity3D tutorials on their website (http://unity3d.com/learn/tutorials/projects/roll-a-ball/moving-the-player) I have come across "generic functions". http://docs.unity3d.com/Manual/GenericFunctions.html In C++ speak, I would have called them templates. In their UnityScript it looks like this: var obj = GetComponent.<Rigidbody>(); I've tried looking elsewhere online to get a rundown of exactly how this stuff works, and how I can write UnityScript code that uses it,

Unity With C# script : Class Data Type Passing Value From Class With Data Twice Weird

心已入冬 提交于 2019-12-02 03:06:45
I got a simple Question and weird from passing value to data type class variable. the code like below : void AddItem(int ID) { for (int i = 0; i < database.items.Count; i++) { if(database.items[i].itemID == ID) { itemxs = new item (database.items [i].itemName, database.items [i].itemID, database.items [i].itemDesc, database.items [i].harvest, database.items [i].itemTime, database.items [i].stdprice, database.items [i].hightprice, database.items [i].itemStock, database.items [i].Lvlunlock, database.items [i].rawTree, database.items [i].itemType, database.items [i].itemProd, database.items [i]

UnityScript “generic functions” in Unity 5

半腔热情 提交于 2019-12-02 00:29:49
While following through the Unity3D tutorials on their website ( http://unity3d.com/learn/tutorials/projects/roll-a-ball/moving-the-player ) I have come across "generic functions". http://docs.unity3d.com/Manual/GenericFunctions.html In C++ speak, I would have called them templates. In their UnityScript it looks like this: var obj = GetComponent.<Rigidbody>(); I've tried looking elsewhere online to get a rundown of exactly how this stuff works, and how I can write UnityScript code that uses it, but I've come up empty. I wonder if I'm just not searching for the correct terms. They say that

Unity. Function call after a certain period of time

China☆狼群 提交于 2019-12-01 19:19:14
How can I make an object invisible (or just delete) after a certain period of time? Use NGUI. My example (for changes): public class scriptFlashingPressStart : MonoBehaviour { public GameObject off_Logo; public float dead_logo = 1.5f; void OffLogo() { off_Logo.SetActive(false); } //function onclick button //remove item after a certain time after pressing ??? void press_start() { InvokeRepeating("OffLogo", dead_logo , ...); } } Use Invoke rather than InvokeRepeating. check Invoke function here public class scriptFlashingPressStart : MonoBehaviour { public GameObject off_Logo; public float dead