unity5

ThirdPersonController collision not calling OnTriggerEnter event

自作多情 提交于 2019-12-02 16:29:18
问题 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Test : MonoBehaviour { public Transform target; // Update is called once per frame void Update () { } private void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Test") { this.transform.position = target.position; } } } I have a ThirdPersonController and i want it to collide with a cube or cylinder. The script is attached to the ThirdPersonController. I tried to add either to the cylinder or

How can i change each gameobject movement speed?

我的梦境 提交于 2019-12-02 13:22:05
In the Hierarchy i have 2 ThirdPersonController. In the Window > Animator i created new empty state called it Walk and set it to HumanoidWalk so when running the game both players are walking. On one of them i added the script and as Prefab the second ThirdPersonController(1). Then when running the game it's making clones of the ThirdPersonController(1). So i see in the Hierarchy more N ThirdPersoncontrollers. Today to change the speed of walking for each ThirdPersonController i change in the Inspector the Move Speed Multiplier. But if i want in the script already when creating the clones to

Unity 5 An object reference is required for the non-static field, method, or property error

為{幸葍}努か 提交于 2019-12-02 13:22:05
In Unity 5 using c# on line 35 of my PlayerMovement class I have this error: Error CS0120 An object reference is required for the non-static field, method, or property 'GameManager.completeLevel()' PlayerMovement Class: using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { public GameObject deathParticals; public float moveSpeed; private Vector3 spawn; // Use this for initialization void Start () { spawn = transform.position; moveSpeed = 5f; } // Update is called once per frame void Update() { transform.Translate(moveSpeed

SmackInitialization: Could not determine Smack version

心不动则不痛 提交于 2019-12-02 13:20:00
问题 I am making an android plugin for Unity, I need to integrate XMPP in Unity so first I am trying to create a connection of XMPP and send and receive a message. It's working fine in android, I am able to send and receive message But when I export .jar file and use in Unity so I got below error while I create connection SmackInitialization: Could not determine Smack version java.lang.NullPointerException: lock == null at java.io.Reader.<init>(Reader.java:64) at java.io.InputStreamReader.<init>

Create a health bar

时间秒杀一切 提交于 2019-12-02 13:17:40
I am trying to create a working health bar, and I have tried methods like Creating GUI.Box() that contains the health bar texture that I have created, but this makes the health bar resize to scale like this: Resizing the texture itself without the GUI.Box(), using the Texture2D.Resize() Method, but when I used the Texture2D.Resize() method, my texture turned black . It looks like this: My code looks like this. It was edited so that the irrelevant parts were deleted for ease of reading. Why does my health bar turn black when I resize it? Are there any ways I can prevent this from happening?

Enemy spawn system. I want easy enemies to spawn first then medium after that i want hard enemies to spawn nonstop. i want it a endless spawn Please [closed]

↘锁芯ラ 提交于 2019-12-02 13:07:37
Currently i have spawning system that spawns Easy then medium enemies but I'm getting Array out of range error and it's only spawning 4 of the enemies. i want x20 easy (or general number) x20 medium and then random between (easy,medium and hard enemies.) This is my Code: using UnityEngine; using System.Collections.Generic; using UnityEngine.UI; public class Test : MonoBehaviour { public GameObject[] enemy; public Transform[] spawnPoints; private float timer = 2; int index = 0 ; int wave = 0; List <GameObject> EnemiesList = new List<GameObject>(); private int enemyCount=20; void Update() {

Clone/duplicate an existing GameObject and its children

℡╲_俬逩灬. 提交于 2019-12-02 11:55:03
问题 Is there a C# way in Unity to duplicate an existing GameObject and all of its children? In my case, I have an empty GameObject with a number of Text objects as children and I would like to create a copy of them all, including relative positions, text values, font, colors, etc.... Prefabs won't work easily because I want to copy the object including its current state. 回答1: The Instantiate function is used to clone any GameObject and its hierarchy. public GameObject rootObj; void Start() {

Greyed out my codes of null checking before invoking a delegate

我怕爱的太早我们不能终老 提交于 2019-12-02 11:04:25
问题 I write unity codes in VS 2015, which means it's in c#4 and the null condition operator is not available. Before invoking a delegate, I did a null check. However the codes are greyed out. Does it mean the grey codes are not effective just like comments? If so what should I do to prevent invoking a null delegate? public delegate void PtjAnimCtrlDelegateColiderSetEnabledTo(bool value); public PjtAnimCtrlDelegateColliderSetEnabledTo colliderSetEnabledToHandler; public delegate void

unity Shader returns a NULL when using Shader.Find

夙愿已清 提交于 2019-12-02 10:57:28
问题 As stated here I am not the only one finding the following problem: Shader.Find returns a Null. In the link above they gave a solution by creating something(?) in the Resource Folder, but I am not sure I understand. First, is this necessary for all cases? (meaning Shader.Find does not work by itself?) Second, what should I add? An unlit shader?? a material? Very confused here 回答1: I could solve the problem finally by doing the following: First, go to unity editor: Edit->Project Settings->

Unity3D - Replay a non-looping Particle System

醉酒当歌 提交于 2019-12-02 08:46:27
问题 I'm following the Survive Shooter Unity3D tutorial and have come across several inconsistencies between the Unite Day presentation and actual behavior in Unity 5.3, such as animation transition and other small issues I had to figure out to achieve the desired gameplay result and follow the tutorial. One issue I'm unable to resolve is replaying a non-looping particle system. In the game hit particles are emitted whenever an enemy is shot, but when running the game these particles are emitted