r/UnityHelp • • Aug 23 '23

SPRITES/TILEMAPS Help! My animated crosshair sprite is not appearing in the game window

3 Upvotes

Hello I'm a beginner in unity. Today I implemented a animated crosshair using sprites. When I now tested it, it seems to only animate and appear in the scene window but not in the game window.

please help!


r/UnityHelp • • Aug 19 '23

UNITY Why do the walls look like this and how do I fix it

Post image
3 Upvotes

r/UnityHelp • • Aug 11 '23

UNITY 🌊 I'm not a shader expert, but I managed to create this water shader using shader graph and a lot of people liked it, so here is a tutorial !πŸ˜„ (link in comments)

3 Upvotes

r/UnityHelp • • Aug 07 '23

UNITY How do I change an objects different materials in script if an object has multiple materials attached to it?

3 Upvotes

I am trying to change multiple materials, the orange inner, outer and center, to different colors however I can only figure out how to change one. That is the script attached. Also, I want the materials to be unique in that the material in unity doesn't change, just the current object. So only this object changes couloir, not the whole class or anything else using the same material. Hence, im using render. Any help to figure this out would be appreciated, I cant find anything online.

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class ColourChangCheckpoint : MonoBehaviour

{

public Checkpoints CheckpointTracker;

public int CheckpointNumber;

public Renderer MyObject;

public bool Safety;

public Material\[\] greenFlameMaterials = new Material\[3\];

void Start()

{

	Safety = false;

}

void Update()

{

	if (!(Safety))

	{

CheckpointTracker = GameObject.Find("Checkpoint1").GetComponent<Checkpoints>();

		if (Checkpoints.CheckpointCounter == CheckpointNumber)

		{

MyObject.GetComponent<Renderer>().material = greenFlameMaterials[1];

Safety= true;

		}

	}

}

}


r/UnityHelp • • Jul 29 '23

UNITY Unity editor ignoring left click/right click desktop input from quest controller while in quest desktop view/PCVR

3 Upvotes

So I have scoured the documentation for unity and even tried to find answers to this weird issue but I have gotten no results for what im having specifically.

My issue is that i am editing VR projects in unity editor while also testing those projects in VR

I am using the Quest 2 and every application on my computer, even ones not designed for VR register my quest controller trigger as a left click/right click on hold.

But for some reason unity ignores this input even though by default oculus desktop/PCVR registers this input as left click/right click on hold for all other applications like chrome, notepad, visual studio, even desktop only games on steam register this as such. But again for some reason unity editor completely ignores this input.

Im trying to get unity editor to acknowledge this input so I dont have to keep removing my headset and go to my mouse and keyboard when I want to make a quick change in a project.

anyone know how to fix this?


r/UnityHelp • • Jul 29 '23

PROGRAMMING Function invokes but doesn't see the condition

Thumbnail
gallery
3 Upvotes

I tried to make a final fantasy-like combat and got stuck on function "enemy1" invoking, but not actually proceeding. Both of the conditions of the function are set to true before it is invoked. What is the problem?


r/UnityHelp • • Jul 24 '23

What material settings would be required to make tubes that have the same appearance as neon tubes, specifically with that visible glass exterior?

Post image
3 Upvotes

r/UnityHelp • • Jul 24 '23

Unity is adding odd black squares, any help?

3 Upvotes

r/UnityHelp • • Jun 29 '23

Pico XR Preview error

3 Upvotes

Hi all, I have just started a course on Unity Dev for VR. I am using a Pico Neo 3 device.

Every time I boot up the project for the first time and start a live preview, it works. I am using the Pico Live Preview plugin.

However, if I want to preview it again, without closing and opening project, I get a black screen and the following error.

Does anyone know how I may be able to solve this? It is quite annoying, having to reset every time I want to preview.


r/UnityHelp • • Jun 19 '23

OTHER Help with Library\Package Cache error (I just opened it, and this is what I found I'm a beginner btw)

Post image
3 Upvotes

r/UnityHelp • • Jun 08 '23

How to make enum-driven CustomEditor that allows me to drag prefabs to each field, and get them in code?

3 Upvotes

I've gotten this much:

using UnityEngine;
using UnityEditor;

namespace Creatures
{
	[CustomEditor(typeof(CreatureSpawner))]
	public class CreatureSpawnerEditor : Editor
	{
		public override void OnInspectorGUI()
		{
			serializedObject.Update();

			CreatureSpawner creatureSpawner = (CreatureSpawner)target;

			foreach (CreatureLookup.CreatureTypes creatureType in System.Enum.GetValues(typeof(CreatureLookup.CreatureTypes)))
			{
				EditorGUILayout.BeginHorizontal();
				EditorGUILayout.LabelField(creatureType.ToString(), GUILayout.Width(100));
				EditorGUILayout.ObjectField(null, typeof(GameObject), false);
				EditorGUILayout.EndHorizontal();
			}

			serializedObject.ApplyModifiedProperties();
		}
	}
}

It got me really excited to see the creature types showing up! However, I have absolutely no idea how to get these values OUT. How do I use them from my CreatureSpawner code? I want to be able to call SpawnCreature(creatureType) and have it instantiate the prefab assigned in the editor.


r/UnityHelp • • May 15 '23

No matter where I put Debug.LogError I get an error.

3 Upvotes

Hello guys, I suck at coding and Im trying to a simple dropdown using textmesh pro, no matter where I put "Debug.LogError("Panel scaling value " + glazingWidth);" in the following code I get an error. In update or in the method itself... it lock the game as soon as I use the dropdown or before anything happens.

Thanks for the help.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class Script_UI_DD_GlazingWidth : MonoBehaviour
{
    public TMP_Dropdown dropdown;
    public float uIDdGlazingWidth;
    public List<TMP_Dropdown.OptionData> optionDataList = new List<TMP_Dropdown.OptionData>();
    private List<float> values = new List<float>();


    private void Awake()
    {

    }

    // Start is called before the first frame update
    void Start()
    {
        setDdValue();
    }

    // Update is called once per frame
    void Update()
    {

    }

    void setDdValue()
    {
        // Create and customize the option data for each option in the dropdown
        TMP_Dropdown.OptionData optionData1 = new TMP_Dropdown.OptionData("0.6 mm");
        TMP_Dropdown.OptionData optionData2 = new TMP_Dropdown.OptionData("0.8 mm");
        TMP_Dropdown.OptionData optionData3 = new TMP_Dropdown.OptionData("1.0 mm");
        TMP_Dropdown.OptionData optionData4 = new TMP_Dropdown.OptionData("1.2 mm");

        // Assign float values to each option
        float value1 = 0.6f;
        float value2 = 0.8f;
        float value3 = 1.0f;
        float value4 = 1.2f;

        // Add the option data and float values to the respective lists
        optionDataList.Add(optionData1);
        optionDataList.Add(optionData2);
        optionDataList.Add(optionData3);
        optionDataList.Add(optionData4);
        // ... add more option data as needed
        values.Add(value1);
        values.Add(value2);
        values.Add(value3);
        values.Add(value4);

        // Assign the option data list to the dropdown
        dropdown.options = optionDataList;

        // Subscribe to the dropdown's OnValueChanged event and pass the OnDropdownValueChanged method as the listener
        dropdown.onValueChanged.AddListener(OnDdValueChanged);

        // Set the initial value of the float variable based on the first option
        uIDdGlazingWidth = values[0];
    }

    void OnDdValueChanged(int value)
    {
        if (value >= 0 && value < values.Count)
        {
            uIDdGlazingWidth = values[value];

        }
    }
}

r/UnityHelp • • May 12 '23

animated water shader not working when material ??

3 Upvotes

Hi,

I'm trying to make a stylised water ShaderGraph using voronoi noise.
It's moving around in the shadergraph preview, but when applied to my water plane it shows this weird unmoving grid ?

pls, help T.T


r/UnityHelp • • May 03 '23

Two matters actually, 2D unity project opens in 3D for collaborator and reverts versions from 2022.2.17f1 to 2021.3.6f1

3 Upvotes

Good evening, I am faced with 2 issues and I cannot find the answer to them anywhere. Firstly, for some reason when I use Unity Version Control to upload a 2D project for my collaborator, when he downloads the project, it sets it in 3D, even though itΒ  was created in 2D. Secondly, the project seems to revert versions from 2022.2.17f1 to 2021.3.6f1. (Suspecting that maybe it is because my friend is adding a package I don't know) but it definitely reverts after some changes are made (we don't even have that version installed.)


r/UnityHelp • • May 02 '23

OTHER HELP! How to connect API with AR marker based application on Unity engine

3 Upvotes

Hi guys!

I have a question about API and AR connection on unity engine.

How can I connect Unity engine project made with Vuforia SDK to server/cloud storage (e.g. AWS, Google cloud)?

For example:

There is an application created using the Unity engine (Vuforia SDK).

A person scans the marker and he should get an animation from the server (cloud storage)

In my head it looks like this:

A person scans the marker, the app makes a certain request to the server (by some key) and the server sends the animation to the app, and the app plays it

Please share if anyone has any guides, tips, or videos.

I am new to this topic and would be very grateful!


r/UnityHelp • • Apr 25 '23

TEXTURES Weird flickering light glitch

3 Upvotes

r/UnityHelp • • Apr 24 '23

UNITY How to fix in Unity "A failure occurred while executing com.android.build.gradle.internal.tasks.workers$actionfacade" for Mac?

3 Upvotes

Hi there, I am trying to build a VR project on unity but getting the following error. Can someone help to find a solution?. I already looked through few solutions but nothing helped.

Version of unity is 2021.3.22f1

Thank you.


r/UnityHelp • • Apr 03 '23

error CS0118: 'enemy' is a variable but is used like a type

3 Upvotes

I started a new side scrolling game on Unity, and after watching a video based off of player combat, I'm stuck on an error that I cant fix. I'm very new to coding, so I have no Idea how to solve it. I haven't been able to finish the 2 scripts because I can't play the game until it is fixed. Here is my 2 scripts, and the video I watched: https://youtu.be/sPiVz1k-fEs

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class PlayerCombatScript : MonoBehaviour

{

public Animator animator;

public Transform attackPoint;

public float attackRange = 0.5f;

public LayerMask enemyLayers;

public int attackDamage = 40;

// Update is called once per frame

void Update()

{

if (Input.GetKeyDown(KeyCode.Mouse0)) // Check if left mouse button is being pressed.

{

Attack();

}

}

void Attack()

{

// Play an attack animation.

animator.SetTrigger("Attack");

// Detect enemies in range of attack.

Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, enemyLayers);

// Damage them.

foreach(Collider2D enemy in hitEnemies)

{

Debug.Log("We hit" + enemy.name);

enemy.GetComponent<enemy>().TakeDamage(attackDamage);

}

}

void OnDrawGizmosSelected()

{

if (attackPoint == null)

return;

Gizmos.DrawWireSphere(attackPoint.position, attackRange);

}

}

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class Enemy1 : MonoBehaviour

{

public int maxHealth = 100;

int currentHealth;

// Start is called before the first frame update

void Start()

{

currentHealth = maxHealth;

}

public void TakeDamage(int damage)

{

currentHealth -= damage;

// Play hurt animation

if(currentHealth <= 0)

{

Die();

}

}

void Die()

{

Debug.Log("Enemy died!");

// Die animation

// Disable the enemy

}

}

This is the full error message: Assets\PlayerCombatScript.cs(35,32): error CS0118: 'enemy' is a variable but is used like a type.


r/UnityHelp • • Mar 30 '23

UNITY I really don't know where to go from here...

3 Upvotes

I really don't know what else to do, the game runs fine but as soon as I load this script, unity completely freezes up and I have to use task manager to close it


r/UnityHelp • • Mar 24 '23

UNITY Weird error that only happens on build

3 Upvotes

Alright I'll cut to the chase because I know nobody really cares but Ive driven myself insane trying to figures this out, on build Im getting the following errors in log:

NullReferenceException: Object reference not set to an instance of an object

at AudioManager.Play (System.String name) [0x00024] in <26f5608109b14772906790b35c006f2d>:0

at PlayerHealth.Update () [0x00039] in <26f5608109b14772906790b35c006f2d>:0

I have tried everything and followed like 5 separate stack overflow and unity forums things to try to fix this, the bulk of which helped me finally narrow down exactly where the null is however now I cant figure out how to fix it, but I wont go on about every little thing I tried.

First area:

public void Update()

{

HSN = PlayerPrefs.GetInt("HIGHSCORE");

SN = Score.GetComponent<ScoreManager>().score;

if (HRegan >= HReganR)

{

//area 1

AudioManager.instance.Play("Regan");

//

health++;

HRegan = 0;

}

else

{

HRegan += Time.deltaTime;

}

Second area:

using UnityEngine.Audio;

using UnityEngine;

using System;

[System.Serializable]

public class Sound

{

public string name;

public AudioClip clip;

[Range(0f, 1f)]

public float volume;

[Range(0f, 3f)]

public float pitch;

public bool loop;

[HideInInspector]

public AudioSource source;

}

public class AudioManager : MonoBehaviour

{

public Sound[] sounds;

public static AudioManager instance;

void Awake()

{

if(instance == null)

{

instance = this;

} else

{

Destroy(gameObject);

return;

}

DontDestroyOnLoad(gameObject);

foreach(Sound s in sounds)

{

s.source = gameObject.AddComponent<AudioSource>();

s.source.clip = s.clip;

s.source.volume = s.volume;

s.source.pitch = s.pitch;

s.source.loop = s.loop;

}

}

public void Play(string name)

{

Sound s = Array.Find(sounds, sound => sound.name == name);

s.source.Play();

}

void Start()

{

Play("MainTheme");

}

public void StopPlaying(string name)

{

Sound s = Array.Find(sounds, sound => sound.name == name);

s.source.Stop();

}

}

Im not sure what Im not getting but it works fine up until I try to build, im not sure if Im just not getting it or somethings missing, if anyone has any idea what Im doing wrong or knows how to get this to work I could use the help. This is in unity btw


r/UnityHelp • • Mar 14 '23

Can you help me fps shoot bullet direction problem

3 Upvotes

Hi guys! I am making a simple fps game from this youtube video https://youtu.be/OFXvvuxqPNQ

There is a error that my bullet doesn't go forward,it goes to the left direction can you help me please


r/UnityHelp • • Mar 11 '23

TEXTURES My texture/material is pixelated altho it shouldnt be , would appreciate the help

3 Upvotes

hey guys im a bit of a noob i would appreciate any help or documentation you can send my way! So basically the project im working on is an art gallery where im getting the texture from a solana wallet and applying it on preexisting frames but like the picture showcases the texture is pixelated https://ibb.co/1XtDjQB

so this is my code that applies my texture

                   Texture2D texture=nftData.metaplexData?.nftImage?.file;
                    _texture= texture;
                    name = nftData.metaplexData.data.name;
                    
                    logo.GetComponent<MeshRenderer>().material.mainTexture=texture;

I already tried changing the filter mode/resizing the texture in code and it does go through but does nothing to fix the pixelisation any clue on what i could do would be appreciated!


r/UnityHelp • • Feb 24 '23

Using the Input System I'm getting the error "Could not find active control after binding resolution"

3 Upvotes

I posted this on the Unity Forums but didn't get a response. This is copy and pasted from what I wrote there.

This is for a mobile game using two UI Images as controls, one with an On-Screen Button component, and one with an On-Screen Stick component. I only receive this error after ending Play Mode, not during, when I used my mouse to touch the buttons in the Simulator, or with the remote app. During Play mode everything acts as it should, and if I don't click the buttons with my mouse and instead use my keyboard I won't receive the error.

As everything works properly during play in the Editor I normally wouldn't care, but I believe this is related to an issue I'm having where when actually built and loaded onto an iPhone the touch controls don't work properly. They are incredibly laggy and only respond when pressed occasionally. The game itself is an extremely lightweight 2D proof of concept, so it isn't a case of being too much for the phone.

I'm currently using Unity 2021.3.19f1 with Input System 1.5.0, but this is after upgrading from an earlier version to see if that would fix it. I don't remember the previous version exactly, just that it was 1.4.something.

Any advice on what I can try in order to fix it? Or is there additional information I should provide that I haven't?


r/UnityHelp • • Jan 31 '23

PROGRAMMING Find all int positions in a BoundsInt? (2D)

3 Upvotes

BoundsInt.AllPositionsWithin returns nothing if the z value is 0 since that is how the formula works.

Any way to make it work for 2D? (z value not being a factor)

Making a selection tool for tilemaps in-game and most methods in the tilemap class require the position of the tilebase rather than the actual tilebase itself. So the tool will within a bounds gather all positions within.

But it only works in 3D

Edit: Well I think you just have to make z =1. I feel dumb now