#💻┃code-beginner

1 messages · Page 800 of 1

hidden marten
#

i did i thought you meant "+" 😭 sorry

naive pawn
#

i had an explicit example there that was not using +

hidden marten
#

and this error is popping up too now

naive pawn
#

huh, haven't seen that one before

#

what unity version are you on?

hidden marten
naive pawn
#

maybe try the latest patch for 6.0?

#

that one in particular is probably an editor bug

#

or i guess before that, just check if you're getting it consistently after restart/library reset i guess

hollow forum
#

I am learning coding at tutorial unity and I copied that codes which unity said to copy. when i click play, it wont work

#

red :(.

radiant voidBOT
# naive pawn !input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

hidden marten
#

stuck in this stupid bug for 3 days 😔

hollow forum
naive pawn
#

you're using the old system, so maybe that's the right one think

hollow forum
#

wait one sec

#

im dumb

#

thank you for much 🙏

bronze fossil
#

@naive pawn bro bro
The thing is i changed yield return null to yield return waitforFixedupdate
and it worked because i am never changing my horizontal position via physics system so there is never contradiction in there

#

in this one

naive pawn
naive pawn
#

it sounds like it "works" because with the WaitForFixedUpdate you're breaking it right before physics fixes it

#

just... don't

bronze fossil
#

ok got it thanks 😭😭😭

cerulean shuttle
#

yo is realistic voice chat hard to pull off as solo dev? like you know, different reverb at outside and different one inside some building or behind the wall etc.. im good at physics and im young math teacher but my experience with coding is little to zero

sour fulcrum
#

depends on how realistic you actually need it to be

cerulean shuttle
#

i wanna make mil-sim game

sour fulcrum
#

it's enough of a problem to where i'd suggest at least considering if you actually need it

cerulean shuttle
#

yes i need it v much

sour fulcrum
#

but you can find half measure solutions to it with more primitive checking

#

eg. seeing if someone is just being obscured, or if they are just in a different room

cerulean shuttle
#

there’s this game called “Insurgency” and it’s my fav fps of all time but nowadays its dead and I feel like there needs to be a game like this with updated graphics - hardcore fps like Arma 3, but with tiny maps and no respawn - round based like A and B bomb sites.

#

so I think this vc thing is a must right?

#

but I dont know if I scope too big

sour fulcrum
#

no offense but based on how you are phrasing

#

scope is very too big

#

that kind of game needs a whole team of people who dont need to ask if scope is too big

cerulean shuttle
#

I mean English is my 3rd lang

#

or is it about stuff I talk about?

sour fulcrum
#

how you talk about in approach i guess

#

your english is fine 😄

cerulean shuttle
#

ohh

#

well that’s unfortunate, I guess a bit of vibe coding wouldn’t work in such a game too right?

cerulean shuttle
sour fulcrum
#

nope

#

a lot of vibe coding is over-exaggerated

sour fulcrum
#

a game like that needs a whole team

cerulean shuttle
#

what if I made cs 1.6 game and then just keep updating the graphics?

#

and mechanics too but slightly each time

sour fulcrum
#

that would be a lot closer to viable yeah

#

but unlikely to be a success if this is your first project

#

multiplayer is a pretty big thing to pick up and espicially in a context that requires super optimised and anti cheat based gameplay

cerulean shuttle
#

is there no premade anti cheat that I can use?

naive pawn
#

the definition of "cheating" depends on your game

#

it's also not just the player inputs, but how your player logically acts - if they have information they aren't supposed to for example, that's also cheating

hollow forum
#

why it wont apply as transform?

naive pawn
#

i'm guessing by that "diversos" that your ide isn't configured

#

!vs

radiant voidBOT
# naive pawn !vs
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

hollow forum
#

it just doesnt work

naive pawn
#

ok? configure your ide

#

having a configured ide is a prerequisite

hollow forum
#

in where? in player or smth

naive pawn
#

in your ide

frail hawk
#

follow the bot instructions maybe

naive pawn
#

the thing you code in

#

your ide is not set up properly, instructions to do so have been linked above

hollow forum
#

okay...

#

so, what i do with ide

naive pawn
#

....configure it

#

do you know what an ide is?

hollow forum
#

no 🥀

naive pawn
#

ok, then say so instead of blindly parroting

hollow forum
#

im sorry

naive pawn
#

an IDE is the app you code in, which is visual studio (vs) in your case

#

do these sentences make more sense now

your ide is not configured properly
configure it with the instructions linked above

rancid tinsel
#

any idea what this is?

#

and why it's in changes

frail hawk
#

you might want to google slnx

#

why do you rummage through those internal files

rancid tinsel
#

I didn't rummage through anything

#

these are just git changes

#

eh I'll just git clone again, I'm not sure what I might have done

#

ok it is appearing on a completely fresh git clone for some reason as well... any clue what to do?

#

it might be nothing, but it seems it always goes wrong when I try to mess with git on my own

#

so I want to be safe

regal galleon
#

Can someone help me make a walking, running and jumping player (with wasd keys) and this is how I want it to look like:

sour fulcrum
#

no

#

if you have specific questions maybe

regal galleon
sour fulcrum
#

what don't you understand

#

what specifically do you need help with

#

no one here will do it for you or will walk you through the entire concept step by step

#

if you have specific things you need help understanding thats where this server can assist

polar acorn
#

Why give "here's what I want my character to look like" when asking in the code channel

regal galleon
#

not more

naive pawn
#

please don't crosspost

rancid tinsel
# regal galleon i want a walk, run and jump system

Learn the fundamentals of moving Characters in Unity3d with an introduction to character controllers!

This beginner-friendly tutorial is a thorough break down covering how we can move characters in Unity3d and explains the various options Unity has to offer: the built-in component, rigidbodies and custom character controllers!

SUPPORT THE CHAN...

▶ Play video
regal galleon
#

I already searched for a video but it didn't work

solar hill
#

What didnt work*

frail hawk
#

probably because you posted your image and asked how to move it

solar hill
#

Yeah is that image supposed to be a 3d model or is it just an image?

regal galleon
#

I spent 3 hours working on the movement through all sorts of different tutorials, but none of it worked for me.

frail hawk
#

do you have some code to share

solar hill
#

So this is a 2d game?

rancid tinsel
#

@regal galleon for tutorials start with setting up your IDE

radiant voidBOT
#
<:error:1413114584763596884> Command not found

There's no command called idea.

solar hill
#

Idea notlikethis

rancid tinsel
#

whoops

#

!idea

radiant voidBOT
solar hill
#

Dawg

rancid tinsel
#

WHAT

solar hill
#

!ide

radiant voidBOT
rancid tinsel
#

!ide

radiant voidBOT
solar hill
#

Its not idea

rancid tinsel
#

😭

regal galleon
#

and than

rancid tinsel
#

I know I was flabbergasted at how I made the mistake twice

solar hill
#

We have no clue what you are doing where you have gotten stuck etc.

#

All you did was show us an image and say "i want a movement system"

#

This is not what this place is for

regal galleon
#

i dont know how to make one and a tutorial din't work for me

red rover
#

Try another tutorial

solar hill
#

And again, what didnt work

#

What in particular wasnt working

frail hawk
solar hill
#

Should we?

#

What doey this have to do with input

frail hawk
#

alot actually

#

could be a starting point on how to move something

solar hill
#

This is under the assumption they are failing at inputs

regal galleon
#

i dont know a single line of code and i am new to the program i use unity for only one day

solar hill
#

Not that they are lacking some basic unity knowledge

#

Wow

#

Who could have called it! Me of course

#

!learn

radiant voidBOT
solar hill
#

@regal galleon highly recommend you start off with the learning pathways first

regal galleon
#

Does anyone have a file to share with me so i can download it

red rover
solar hill
regal galleon
#

ok

#

but have you a file for me please

solar hill
#

No and thats not how that works

#

Youre lacking some basic fundamentals of unity and you need to actually learn that first if you want to do anything

#

I promise you its a short step between that and a working character controller

regal galleon
#

but can you do it one time for me please i am new

solar hill
#

No

regal galleon
#

why not

solar hill
#

I cant and wont, listen to what im telling you

frail hawk
#

i am glad you asked here and not somewhere else for random files.. be aware that people might send you malware

solar hill
#

Im not telling you these things for no reason

frail hawk
solar hill
#

Also it isnt even a model

#

Its just an image

regal galleon
solar hill
#

And we dont even know if the game is meant to be 2d or 3d

frail hawk
#

lol bro stop, learn coding learn the basics and you will be able to master things on your own

#

there is a reaoson why people recommend you to do that

red rover
# regal galleon but can you do it one time for me please i am new

If you get the file now, you wont know how to use it
I see from your youtube that you are young, if you want to be a game dev you have to learn, it's sadly not as easy as getting code from others then telling the computer to "make the game"
It's not as easy as you assume, but it's also not that hard to learn. That's actually part of what makes game dev fun

solar hill
#

So you want a 3d character controller for a 2d image of a character you dont have a model for?

#

I think this person is really young and has a misunderstanding about how game development really works

red rover
regal galleon
#

Bro please help me for once

red rover
#

There's the file, right?

regal galleon
#

thanks

red rover
#

So you're good now? Don't need any more help?

regal galleon
#

yes

red rover
#

If you say so

solar hill
#

I give him 10 minutes

red rover
regal galleon
solar hill
#

Oh no reason, good luck

distant escarp
#

i dont mean to ask the same question twice but does anyone know how to recreate the simple noise node in csharp? I just need to know the y-positions that it produces on a shader graph

red rover
#

Noise is deceptively complicated for being so widespread in game dev

#

I would suggest downloading a noise library

#

But if you do want to create your own, I think I have a resource for you

distant escarp
red rover
red rover
distant escarp
#

let me mention that im not trying to recreate a shader graph, i need my player to walk on the shader graph so i need to use a noise that i can recreate in csharp for the code

solar hill
#

honestly i dont see the benefit in not using a preexisting library

red rover
distant escarp
#

no, i want to use the noise in the shadergraph (to make realistic looking waves) and then recalculate the y points that shader graph creates so my character can walk on them

#

basically, i need to know how the noise calculates y values so i can mimic them in physics

solar hill
#

well yeah then the shader graph noise wont be of use

#

iirc theres no way to expose its math in any usable way

#

i dont think its deterministic

distant escarp
#

damn.... should i just use gerstner waves then?

solar hill
#

you could yeah

#

but you would need to implement it on your own

red rover
#

My best guess would be to actually generate the waves in C# but using compute shaders, saving that to a texture, then feeding that texture to the shader graph to turn that texture into waves.

#

That is a complicated task but possible

solar hill
#

its complex but not nescessary

#

you could use a custom hlsl node

#

and feed the parameters from the c# code at runtime

#

so they match

distant escarp
red rover
distant escarp
solar hill
#

my way is a bit more work but it might be better in the long term

red rover
#

kuzmo suggested creating your own mathematical function to sample waves given an input x and z, then to use that function in C# land and in shader graph land.

distant escarp
solar hill
#

but that means you will need both a. c# code to generate the waves and a hlsl node for the exact same things, then you take your own parameteres from the c# script at runtime and feed them into the hlsl node's serialized values

distant escarp
#

okay, i think i can do that (its basically just what i was doing with gerstner waves but with my own custom wave function)

solar hill
#

so basically in your shadergraph you just have to swap out your current noise node for the custom one and then expose the parameters

#

then make sure your c# can access those parameters and change them dynamically

#

this should work and be pretty performant

#

iirc i do something very very similliar in my own project but i use it to recreate random pattern on my enemies using a wave based noise

solar hill
#

anyways its not too disimilliar to what you need to do, i would start by looking up if anyone created a c# script for the wave or even an hlsl node, that would be a good start.

distant escarp
solar hill
#

good luck :)

distant escarp
#

thanks dawg, ill need it

swift crag
#

they're very nice, and the math isn't that bad

visual idol
#

Hey, I have a huge problem with my programming. My quest just won't progress and I have no idea why. Could someone help me? It's for my semester project, which I have to hand in tomorrow night. I'm not desperate, please, dear Unity God, hear me.

swift crag
#

share the relevant code and explain what you've done so far

#

!code

radiant voidBOT
visual idol
#

I don't know what to do, I'm a complete beginner.

grand snow
rich adder
solar hill
visual idol
#

The problem is I don't have any nitro, so I don't know how I can share it with you.

grand snow
#

code is text

#

use the websites linked in that fancy message above

#

!code

radiant voidBOT
grand snow
#

or here

rich adder
rich adder
visual idol
radiant voidBOT
#
<:error:1413114584763596884> Command not found

There's no command called screenshot.

rich adder
#

!screenshots

radiant voidBOT
grand snow
#

wow thats a first

rich adder
#

@visual idol

solar hill
rich adder
solar hill
#

no shaders

#

done entirely with like 2 scripts

grand snow
visual idol
#

den da ?

#

oh soory XD

visual idol
#

my game home

rich adder
visual idol
#

// 6. Brief an der Bank (JETZT WIE DIE BRÜCKE)
questTMP.text = "Untersuche den Brief an der Bank";
if (quest.briefOma != null)
{
quest.briefOma.SetActive(true);
Interactable interBank = quest.briefOma.GetComponent<Interactable>();
if (interBank != null) interBank.onInteract += () => { NextStep(); };
}
questWeiter = false;
while (!questWeiter) yield return null;

    // 7. Blumen (WIE DIE BRÜCKE - Anklicken)
    questTMP.text = "Pflücke die Blumen für das Grab";
    foreach (var blume in quest.alleBlumen)
    {
        if (blume != null)
        {
            blume.SetActive(true);
            Interactable interBlume = blume.GetComponent<Interactable>();
            if (interBlume != null) interBlume.onInteract += () => { NextStep(); };
        }
    }
    questWeiter = false;
    while (!questWeiter) yield return null;

    // 8. Grabstein (Finale)
    questTMP.text = "Bringe die Blumen zum Grabstein";
    while (!quest.grabStein.GetComponent<Grabstein>().hatInteragiert)
    {
        yield return null;
    }

    // 9. Ende
    questTMP.text = "Schnitzeljagd beendet! Gut gemacht!";
}

} // Diese Klammer schließt die Klasse (Fehler CS1513 gelöst!)

#

aba ihr geht er nicht weiter und ich weis nicht warum soory mein englisch ist echt nicht gut und ich weis gerade wie ich antworten soll soory

#

That’s why my code doesn’t continue anymore, I can’t collect the flowers, the bank works, but it stops when going from step 6 to 7, and my English isn’t very good.

rich adder
#

if you sent the links not sure why you pasted the wall of text tho

#

we can see the code, but still if you think something breaks down somewhere debugging is part of fixing something and first steps you should take

#

hard to know what those names mean without being in english tbh

grand snow
#

Okay so what does questWeiter mean

#

waiting for a quest to be completed?

rich adder
#

I'm guessing Interactable is what supposed to grab flowers?

visual idol
#

nay yeas

#

+nav

rich adder
#

by

the bank works
what exactly do you mean ? in what sense it works

grand snow
#

I think the design of this being a coroutine that waits is bad and has contributed to your issue

#

You could store state in a better way and re execute something to check the next part instead.
You already use an event to handle the interaction so you already understand this

rich adder
#

yaquestWeiter is sketchy where does it supposed to set tru

#

this is a coding channel..

mint imp
#

Oh oops most of my problems are coding so just habit my bad

grand snow
#

polybrush is dead so id just learn to sculpt in blender if you already can use it a bit @mint imp

rich adder
grand snow
#

It needs to be revived the mesh placing tool is super useful

mint imp
grand snow
#

Just add better tools to place prefabs and meshes in the engine ffs

visual idol
#

soory mom pleas

rich adder
#

Unity takes over **good **tools and then neglects them

#

classic

visual idol
#

"i am collecting the letter, and it’s actually supposed to open a ui panel (an image i already made in unity). but right now, it just collects the item and doesn't progress to the next quest. in the next quest, i need to collect flowers and put them on the gravestone to finish my game."

rich adder
grand snow
visual idol
#

withing for my dialog

grand snow
#

sorry is that a yes or no?

visual idol
#

end withinf for my items blume brief

grand snow
#

oh shit you re use the same variable many times nvm

#

I give up 🤷‍♂️

visual idol
#

soory my englsich is verry bad XD

solar hill
#

we cant really help you if we litterally cant understand what your code says

visual idol
rich adder
# visual idol

are you getting this log

Debug.Log("QuestManager: Signal erhalten!");

visual idol
#

"should i stream my screen so it's easier to understand?

solar hill
#

no

naive pawn
#

no, there are intentionally no vc's here

solar hill
#

that would hte exact opposite here

naive pawn
#

you can use screen recordings if you think that'll help illustrate

mint imp
#

Im having an issue with rotating my player to match camera but limiting the player rotation.

This function just lerps my players rotation to face the same way the camera is pointing
(Its a 3rd person spaceship for context)
How can i make the player follow the camera EXCEPT keep x at 0

sour fulcrum
#

make the player follow the camera

#

then keep x at 0

mint imp
#

but how ive tried that in every way i can imagine and the behavior is weird

sour fulcrum
#

well we can't guess those ways, you'd have to show them

mint imp
#

okay let me whip one up

misty sand
#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;

public class MonsterControllerV2 : MonoBehaviour
{
    public NavMeshAgent ai;
    public Transform player;
    public Camera playerCam, jumpscareCam;
    public float aiSpeed, catchDistance, jumpscareTime;
    public string sceneAfterDeath;
    private Animator mAnimator;

    private Renderer rend;

    void Start()
    {
        rend = GetComponentInChildren<Renderer>();
        mAnimator = GetComponent<Animator>();
    }

    void Update()
    {
        Plane[] planes = GeometryUtility.CalculateFrustumPlanes(playerCam);
        float distance = Vector3.Distance(transform.position, player.position);
        bool visible = GeometryUtility.TestPlanesAABB(planes, rend.bounds);

        if (visible)
        {
            ai.speed = 0f;
            ai.SetDestination(transform.position);
        }
        else
        {
            ai.speed = aiSpeed;
            ai.SetDestination(player.position);
            if(distance <= catchDistance)
            {
                player.gameObject.SetActive(false);
                jumpscareCam.gameObject.SetActive(true);
                StartCoroutine(killPlayer());
            }
        }
    }
    IEnumerator killPlayer()
    {
        mAnimator.SetTrigger("TrJumpscare");
        yield return new WaitForSeconds(jumpscareTime);
        SceneManager.LoadScene(sceneAfterDeath);
    }    
}```
 Here is the script that I am using for the monsters movement. I want to add a system where if the player is looking at the monster for too long (for example 5 seconds) the monster will teleport to a new location. I want this location to be the same distance that it was away from the player before teleportation however I want it to be somewhere else around the circumference of the player.  what would the simplest/ easiest method of doing this be for a beginner?
wintry quarry
#

do we care about colliding with walls etc?

radiant voidBOT
mint imp
misty sand
sour fulcrum
rich adder
sour fulcrum
#

thats not what i said

#

make the player follow the camera
then keep x at 0

wintry quarry
#

you are getting confused between rotations that are expressed as sets of Euler angles, which are x, y, z

#

and Quaternions

#

Quaternions have x, y, z, and w and they ARE NOT EULER ANGLES

#

they cannot be used as euler angles

#

you are best served forgetting they exist

#

Can you explain what you're trying to do with this code?

#

transform.rotation is a Quaternion, it is not a set of euler angles

#

are you just trying to get a "flat" version of the rotation of the camera?

#

Like, so your player can move in the direction of the camera but without going up or down?

#

If so, do this:

Vector3 cameraForward = cameraRoot.transform.forward;
Vector3 flatForward = Vector3.ProjectOnPlane(cameraForward, Vector3.up);
Quaternion targetRotation = Quaternion.LookRotation(flatForward, Vector3.up);```
#

(this is assuming a universal "up" direction)

#

you explained something about planets so we might need to get a little fancier

#

is that the case?

rich adder
#

@misty sand
basically what i would do, assuming this is 3D.

Vector3 origin = player.position;
float distance = 5f;

Vector2 randomDirection2D = Random.insideUnitCircle.normalized;
Vector3 spawnPosition = origin + new Vector3(
    randomDirection2D.x,
    0f,
    randomDirection2D.y
) * distance;```
that *should * work, I think
mint imp
# wintry quarry Can you explain what you're trying to do with this code?

I have a parent object that maintains a distance around a planet, and orients itself so "forward" is aligned to the horizon.

I have 2 children that can rotate freely
A camera root
and the actualy spaceship
The camera can look around left and right, up and down (Respective to parent object)
Right now the spaceship follows that movement
Whiche allows you to "look down" and fly towards the planet
I want the spaceship to rotate left and right with the camera, buy not look up and down.

My movement is based on which direction the spaceship is facing, so looking down gives unwanted results

misty sand
frail hawk
wintry quarry
mint imp
wintry quarry
#

like:

Vector3 cameraForward = cameraRoot.transform.forward;
Vector3 flatForward = Vector3.ProjectOnPlane(cameraForward, parentObject.transform.up);
Quaternion targetRotation = Quaternion.LookRotation(flatForward, parentObject.transform.up);```
mint imp
misty sand
# frail hawk you have to seperate your issue into smaller pieces. Start with the player looki...
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;

public class MonsterControllerV2 : MonoBehaviour
{
    public NavMeshAgent ai;
    public Transform player;
    public Camera playerCam, jumpscareCam;
    public float aiSpeed, catchDistance, jumpscareTime;
    public string sceneAfterDeath;
    private Animator mAnimator;
    public float currentTime;
    public float TimeLimit = 5.0f;

    private Renderer rend;

    void Start()
    {
        rend = GetComponentInChildren<Renderer>();
        mAnimator = GetComponent<Animator>();
    }

    void Update()
    {
        Plane[] planes = GeometryUtility.CalculateFrustumPlanes(playerCam);
        float distance = Vector3.Distance(transform.position, player.position);
        bool visible = GeometryUtility.TestPlanesAABB(planes, rend.bounds);

        if (visible)
        {
            ai.speed = 0f;
            ai.SetDestination(transform.position);
            currentTime = Time.deltaTime;
            if(currentTime >= TimeLimit)
            {
                
            }
        }
        else
        {
            ai.speed = aiSpeed;
            ai.SetDestination(player.position);
            if(distance <= catchDistance)
            {
                player.gameObject.SetActive(false);
                jumpscareCam.gameObject.SetActive(true);
                StartCoroutine(killPlayer());
            }
        }
    }
    IEnumerator killPlayer()
    {
        mAnimator.SetTrigger("TrJumpscare");
        yield return new WaitForSeconds(jumpscareTime);
        SceneManager.LoadScene(sceneAfterDeath);
    }    
}``` ive added the timer system now i just need to teleport the monster to the transform
wintry quarry
#

that logic is not right

mint imp
# wintry quarry Can't you just use the parent object's orientation then?

This is a function in my parent object that handles keeping the entire gameobject level with the planet surface
it doesnt rotate with turning, because thats what my cameraroot is for.

Im already rotating spaceship with parent to a degree
but when i want my spaceship to face towards the camera for turning the ship and always moving forward thats when i need it to follow my camera (which is also rotating with gameobject inherently)

wintry quarry
misty sand
misty sand
# wintry quarry ```cs currentTime = Time.deltaTime; if(currentTime >= Ti...
        {
            ai.speed = 0f;
            ai.SetDestination(transform.position);
            currentTime += Time.deltaTime;
            if(currentTime >= TimeLimit)
            {
                
            }
        }
        else
        {
            currentTime = 0;
            ai.speed = aiSpeed;
            ai.SetDestination(player.position);
            if(distance <= catchDistance)
            {
                player.gameObject.SetActive(false);
                jumpscareCam.gameObject.SetActive(true);
                StartCoroutine(killPlayer());```
frail hawk
#

what does that line do
bool visible = GeometryUtility.TestPlanesAABB(planes, rend.bounds);

misty sand
wintry quarry
#

it's checking if the renderer's bounds is inside the camera's frustum

#

it's not perfectly accurate but is decent

mint imp
wintry quarry
#

because your code is setting the up direction

#

notably though your code is only really setting the up direction of the "root", not the forward direction.

misty sand
#

what would you of done differently out of curiosity?

wintry quarry
# misty sand what do you mean?

it's all based on AABBs, there will be some cases where the edge of the bounding box is just barely in the frustum and you'll get a true result even if the player can't actually see the thing

#

I wouldn't necessaarily do anything differently

#

it depends on your requirements

#

this is a fast approach

#

if you need more accurate results you'd need to do something a little more complicated like testing a collection of predefined points within the object's mesh itself

rich adder
#

you could probably make "key points" placed on places like each hand, feet etc..
then check those with some type of Dot product or something.

#

takes more work tho

frail hawk
#

or a raycast

misty sand
#

it was just the first method i saw to achieve my desired function, the game im making is only a small 4 week project for college so it works well enough for me.

rich adder
#

true ray or bigger cast might be better to be precise / behind walls. Id use dot too for angles

rich adder
mint imp
misty sand
rich adder
# misty sand what do you mean?

I want this location to be the same distance that it was away from the player before teleportation however I want it to be somewhere else around the circumference of the player. what would the simplest/ easiest method of doing this be for a beginner?

misty sand
#

ive only set up the timer so far, still trying to figure out how to do the teleport part

rich adder
#

well code I sent, if works gives you that position, just apply it to whatever it is you're using

misty sand
#

do you think you could explain it slightly, im still trying to learn c#

rich adder
#

usually =

#

mything.postion = newPosition

misty sand
#

yeah i am using a navmesh

misty sand
# rich adder its a simple assign operation
        {
            ai.speed = 0f;
            ai.SetDestination(transform.position);
            currentTime += Time.deltaTime;
            if(currentTime >= TimeLimit)
            {
                float currentDist = Vector3.Distance(transform.position, player.position);

                Vector2 randomDir = Random.insideUnitCircle.normalized;
                Vector3 dreamPos = player.position + new Vector3(randomDir.x, 0, randomDir.y) * currentDist;

                NavMeshHit hit; 

                if (NavMesh.SamplePosition(dreamPos, out hit, 5f, NavMesh.AllAreas))
                {
                    ai.Warp(hit.position);
                }
            }
        }```
#

does this look good?

rich adder
#

you might need to reset timer as well

misty sand
#

it doesnt appear to be working

#

i can look at it for however long i want without it teleporting

#

ill send the current code

rich adder
#

check console and also put logs make sure no errors / warnings

misty sand
#

im not getting any errors or warnings, can i send the code as a ss cus i hit the character limit

rich adder
#

send thru link sites

#

👇

radiant voidBOT
misty sand
rich adder
#

putting logs inside blocks where conditions must be met is important to verify code is reaching there

misty sand
#

what line should i put a log?

rich adder
#

inside the codeblocks where conditions must be met

#

eg
if(something)
{ Log }

#

etc.

frail hawk
#

start with the visible bool

#

is this bool even true , so as nav said use a bool right after you enter the scope

misty sand
#

so the time is working but the if statement straight after isnt

rich adder
frail hawk
#

reset the timer otherwise your code inside the if statetment will be executed permantently

misty sand
# rich adder yu mean `NavMesh.SamplePosition`
            {
                Debug.Log("working");
                float currentDist = Vector3.Distance(transform.position, player.position);

                Vector2 randomDir = Random.insideUnitCircle.normalized;
                Vector3 dreamPos = player.position + new Vector3(randomDir.x, 0, randomDir.y) * currentDist;

                NavMeshHit hit; 

                if (NavMesh.SamplePosition(dreamPos, out hit, 5f, NavMesh.AllAreas))
                {
                    ai.Warp(hit.position);
                }
            }``` this part doesnt run apparently
rich adder
#

so Debug.Log("working"); isnt printing?

#

also log is missing in SamplePosition if statement to see if it even gets there

misty sand
#

its not printing, how would i write it with in sampleposition?

rich adder
#

currentTime = 0; this should be inside the IF current > Limit

#

otherwise your'e setting to 0 on the Next frame never reaching TimeLimit

misty sand
#

so how would that line look?

rich adder
rich adder
#

you put it outside of it

misty sand
#

oh yeah

rich adder
#

so it going current += in one frame then right after sets to 0 and keeps going

misty sand
#

should it go after the warp?

#

like the last line in that if statement ( the currenttime >= one)

rich adder
#

as long as inside here

if(currentTime >= TimeLimit)
            {
.....
            }```
#

"timer reached, good set to 0 we don't need you right now "

misty sand
#
            {
                Debug.Log("working");
                float currentDist = Vector3.Distance(transform.position, player.position);

                Vector2 randomDir = Random.insideUnitCircle.normalized;
                Vector3 dreamPos = player.position + new Vector3(randomDir.x, 0, randomDir.y) * currentDist;

                NavMeshHit hit; 

                if (NavMesh.SamplePosition(dreamPos, out hit, 5f, NavMesh.AllAreas))
                {
                    ai.Warp(hit.position);
                }
                currentTime = 0;
            }```
#

like this?

rich adder
#

it doesnt matter if its on the first line or last line, as long as its that block. Its all happening on the same frame

misty sand
#

finally

rich adder
#

there are no early return so all those lines will run, even if Sample is run

misty sand
#

@rich adder i gotta say i really appreciate the help. im sorry for all the questions but after this conversation im sure you can definitely tell im new to coding and unity. thank you for sticking with me and not giving up!!

rich adder
#

is the teleporting working

misty sand
#

yeah it is, the only weird thing is that the debug message will run in the console but it wont teleport 100% of the time

#

ill send a vid to show you

ivory bobcat
rich adder
#

ya you could also add log there too and be sure 100% is either running the warp or not at all

#

5f is a pretty generous distance but you could also verify what dreamPos is if you use a DrawLine or something

#

wish we had a Debug.DrawSphere

#

anyway Debug.DrawLine(transform.position, dreamPos, Color.Red, duration: 5f) before If(SamplePos)

misty sand
rich adder
#

add additional check, either the fustrum thing or dot prod could work too prob

#

as to why its not doing newpos every time , you need to check the logging I suggestion above

misty sand
#

i added the debug for the red line and it did this when not teleporting

rich adder
#

looks like its putting new pos in the ceiling somehow

misty sand
#

it also made a line when the teleport did work

rich adder
#

dreamPos = player.position + new Vector3(randomDir.x, 0, randomDir.y) * currentDist;

I think issue might be stemming from adding playerPositions y pos * dist

#

if player is at 2f and you do 2 * 5 you get 10, a very ceiling pos lol

#

with terrain like this it gets tricky, I assumed it was flat ground at first

misty sand
#

so what do you think the best thing to do would be?

frail hawk
#

how about a list of Vector 3 you define in your inspector and then randomly place your enemy on one of these

misty sand
#

what would this look like?

rich adder
#

nah I'd do maybe

Vector3 horizontalOffset = new Vector3(randomDir.x, 0f, randomDir.y) * distance;
Vector3 dreampos = new Vector3(
    player.x + horizontalOffset.x,
    agent.transform.position.y,
    player.z + horizontalOffset.z
);
``` forgot the names so i renamed it
#

and you would need put it in some sort look and test first if its within players view, if it is keep trying

#

dot product should work fine enough i think

#

might stil be an issue tho with the agents Y pos

#

perhaps you could sample the terrain / ground first and use that Y

#

like sample it from high enough Y down to ground with a ray, then use that Hit pos's Y only on ground layer

misty sand
rich adder
#

but yeah I think 100% ray down is the way to go

misty sand
#

Yeah okay all good. I think I’ll tag you. Thanks again for all the help you’ve given I really appreciate it

prime goblet
#

hello
im using the current

Physics.simulationMode = isToggled ? SimulationMode.Script : SimulationMode.FixedUpdate;

to handle pausing/unpausing physics, however when i pause physics, raycasts seem to break. is there any reason/fix for this?

(second recording is just to show that when physics is always enabled nothing goes wrong)

grand snow
mild lake
#

Does anyone know how i could pixelate jus these shadows?

grand snow
prime goblet
#

interesting, if i have any more issues i'll look into that

eternal needle
prime goblet
#

i basically just wanted to disable any physics from happening, so i dont have anything responsible for simulating physics

eternal needle
prime goblet
#

if you have any suggestions i'd be happy to try them, but what rob suggested is working for me and im not going to be messing with physics any further than this requirement of it being turned off and on

eternal needle
#

i do find it very weird that syncing transforms fixes that considering those objects aren't moving

molten otter
#

what's the Unity.Physics (DOTS) equivalent to this code snippet? I can get the collider through an entity's PhysicsCollider component but it doesn't seem to have any bounds?

grand snow
molten otter
#

capsule

#

do I need to cast it to a CapsuleCollider?

wintry quarry
#

no

#

it cannot be cast to CapsuleCollider

#

that's a totally different physics engine

pure pine
#

hey so here im using a coroutine to add a delay between the shots being fired to prevent spam , is this efficient or is there a better way

#

dont mind the sneeze btw

wintry quarry
frosty hound
#

Definitely don't want to use coroutines for that sort of thing. Track cooldowns in update, so that you can interrupt and manage them easier.

frosty hound
#

Lol

pure pine
wintry quarry
#

Using a timer variable in Update or FixedUpdate is the best way

pure pine
wintry quarry
# pure pine how do i do that , do i just create a variable and set it to increase by 1 value...

something like this:

float timer = 0;
public float shotsPerSecond;
float shotInterval => 1f / shotsPerSecond;
bool fullAuto = false;

void Start() {
  // start off primed and ready to shoot
  timer = shotInterval;
}

bool ShootInputPressed() {
  return fullAuto ? Input.GetKey(KeyCode.Space) : Input.GetKeyDown(KeyCode.Space);
}

void Update() {
  timer += Time.deltaTime;
  
  if (timer >= shotInterval) {
    if (ShootInputPressed()) {
      timer -= shotInterval;
      Shoot();
    }
    else {
      timer = shotInterval;
    }
  }
}```
pure pine
#

can u explain this line? "float shotInterval => 1f / shotsPerSecond;"

#

bool ShootInputPressed() {
return fullAuto ? Input.GetKey(KeyCode.Space) : Input.GetKeyDown(KeyCode.Space);
this too

rich adder
#

? : is a ternary operator

#

basically a one line if else statement

pure pine
rich adder
rich adder
#

please use links for large code

#

!code 👇

radiant voidBOT
fallen mural
#

oop sorry

rich adder
pure pine
pure pine
rich adder
# pure pine and that too

=> makes it a get read only property, get/setters are functions basically that run when you access a property.
so everytime you access shotInterval it calculates the interval based shots per second
(so you wouldnt be able to modify the shotsPercond manually somewhere else in code, and there is no need to)

fallen mural
#

can someone please help me figure out why my enemy isnt flipping when the player enters the back collider? the enemy script is attached to the main Enemy game object, and the EnemyAI script is attached to each of the front and back collider game objects
Enemy script: https://paste.mod.gg/afitpicjwiyl/0
EnemyAI script: https://paste.mod.gg/wjjojimxprht/0

#

the detecting for if the player is in front/behind works btw just not the flip logic

#

the flip method works too since I use it for walls

pure pine
rich adder
fallen mural
rich adder
#

fields / variables are the ones stored

pure pine
rich adder
#

if done in a void it just stops or return out the function

#

but you don't return a value, like the others do

pure pine
#

like is this the math / or is it smth else

rich adder
#

yea this function just returns a simple division operation

rich adder
pure pine
rich adder
#

nothing wrong with being new to c#

#

gotta start from basics, everyone did

pure pine
#

final question , in the code he provided how do we control the amount of shots per second

pure pine
rich adder
rich adder
pure pine
rich adder
pure pine
#

i also mean that

rich adder
#

I mean C++ / C has return values lol

pure pine
rich adder
#

surely you used return before

pure pine
#

i just never understood them

#

even tho its just a simple thing that returns a value from a function

rich adder
#

ya in this case the name literally explains it straightforward lol

pure pine
#

imma go back to unity now

#

ty for the help

#

(lowkey dont tell the other ppl here im stupid cus they still dont know that UnityChanThumbsUp )

rich adder
#

eh no reason to put yourself down, its important to ask what you're confused on. suggesting doing the basic courses isn't implying anything negative on you, it helped us all reach where we at now

hoary nova
#

hey, can you guy gimme me some help? I don't want to use anymore ai chatbots to help me with my game so I am gonna talk with other human beings, I know, incredible

anyway here is the code that gives me nightmares:

public UpGradeSO getRandomSO()
{
int random = Random.Range(0, upgrades.Count);
UpGradeSO randomSO = upgrades[random];
if (randomSO.requiresUnlock)
{
if (!abilitiesOBJ[random].GetComponent<Abilities>().unlocked)
{
return getRandomSO();
}
}
if (!upgrades[random].stackable)
{
upgrades.Remove(upgrades[random]);
}
return randomSO;
}

now what I want it to do I get a random scriptable object for an level up/upgrade system, and this little function gets a random scriptable object off a list, but I wanted it to check if the ability is unlocked, and if not, don't give a scriptable object that requires to be unlocked
I know, this code is a** and for some reason, instead of returning a new scriptable object when its required to be unlocked, it jusst returns null, please send help my brain decided to soft lock itself and I dunno what to do

rich adder
#
if (!upgrades[random].stackable)
{
    upgrades.Remove(upgrades[random]);
}``` pretty sketchy

imagine you have
If upgrades.Count == 0, Random.Range(0, 0) gives you:
index 0
but there is no element 0
so randomSO ends up null
warm crater
#

Is it fine to keep my camera code in the same script as the player movement?

#

I have it all in a playercontroller script right now

rich adder
#

generally you want different components per responsibility

warm crater
#

Yeah it is. I even have regions in the script set up to seperate the camera and movement

rich adder
#

in the beginning though its acceptable, but monoliths quickly scale and become unmanageable

#

especially debugging

wintry quarry
warm crater
pure pine
# wintry quarry Yes exactly this

alr dude tysm , imma be using this code from now on , i just implemented it and added the fullauto toggle and daim ngl thats awsome

rich adder
#

though an event might work better

ivory bobcat
sharp fractal
#

Hello, everyone.
I’ve been trying to find a suitable algorithm for checking the ground under the player’s feet for two weeks now, and I haven’t come up with anything.
Let me explain: to adjust the player’s direction of movement, I need to get the surface normal (as in all tutorials), but SphereCast/CapsuleCast at the edges give the normal in the direction of the point of contact, not the real one. Because of this, the player “slides down.” The effect is shown in the image below.
This isn’t the first time I’ve seen this in various controllers, but I don’t like this effect. I’m guided by games such as Quake, Half-Life 2, and Portal 2, where this doesn’t happen.
When studying the above games using the console, I discovered that they used BoxCollider instead of CapsuleCollider. However, I am told that no one does this now, although I do not understand why.
In general, please point me in the right direction. I cannot yet figure out the best course of action on my own, as I have little experience in game development.
Thanks in advance!

wind kite
#

Hi, does anyone know how I can make a vehicle destruction system based on states? For example, we have our car separated into different parts, each part with a certain amount of health. When the car is hit in one of those parts, the part loses health. When it reaches a certain health level, the part's model changes to a bent version, until it detaches from the car, maybe using triggers and prefabs??? if anyone knows about an existing tutorial or something i can check it would be very useful

rich adder
wind kite
#

wdym

rich adder
#

there are multiple things you have to do but are you asking about checking the value ? spawnning

#

damage ?

wind kite
#

i mean, i want to know first if there are guides already existing on this topic, ive researching and found nothing

rich adder
#

instead of "how to do exactly xyz" "how to do x" then "how to do y"
then put everything together

wind kite
#

ok

rich adder
# wind kite ok

Start with the health system, and log / do something when within specific range. This is an easy thing to start with
"how to map number based on specific ranges C#"

#

if else statement, a dictionary etc..

#

many solutions

ivory bobcat
# ivory bobcat Copy the collection and remove elements that do not qualify. Then select a rando...
var results = new List<UpGradeSO>(upgrades);//GC: pool instead and avoid having to differentiate
for(int i = 0; i < results.Count;)
{
    if((!abilitiesOBJ[i].GetComponent<Abilities>().unlocked)
        results.RemoveAt(i);
    else
        ++i;
}
if(results.Count < 1)
    return null;//Or throw an error. There weren't any valid objects.
int random = Random.Range(0, results.Count);
var randomSO = results[random];
if(!randomSO.stackable)
    upgrades.Remove(randomSO);
return randomSO;``` @hoary nova 
But personally, I would rather just have a single collection that references both upgrade and ability.
warm crater
rich adder
warm crater
#

Oh

rich adder
#

only the movement script for example can modify it

#

but every script can read / use it

grand snow
#

you dropped your private set;

rich adder
#

!code 👇

radiant voidBOT
grand snow
#

(unless this is an interface)

rich adder
pure pine
rich adder
#

i usually link it to a field MoveSpeed => moveSpeed [SerializeField] private moveSpeed

rich adder
grand snow
#

I like to avoid explicitly doing a backing field if possible because of it being easy to refer to both inside the class

#

but yea if you want a public getter only that works too

rich adder
#

true.. I once saw something with naming, tbh I don't quite remember if it messed with anything

grand snow
#

yea the backing field does have a prefix making it hard to change it to a plain field later but i dont mind that

#

We can work around that with formally serialized as like any other rename

rich adder
#

oh okay thats pretty tame then

warm crater
#

It can certainly be better right

ivory bobcat
rich adder
#

thats not its responsibility

warm crater
rich adder
pure pine
ivory bobcat
pure pine
#

Its in the else of the if function

warm crater
#

Yeah I might just stick with a single script for now

pure pine
rich adder
warm crater
#

Oh

#

That didn't cross my mind

rich adder
#

imagine you have an Icon that shows up when you're scoped in ? / aimed or something else needs to happen, now you're gonna have huge amount of code controling UI too or if you have multiple scripts you got all sorts of spoons in that soup, like camera controlling UI now?

#

a centralized place where different scripts can find a common value, easy. Yes it can be done with monolith but then debugging will be a mess and not very extensible

warm crater
#

So instead I should handle the movement part of the aiming mechanic in the movement script and the camera part in the camera script?

rich adder
#

if you have public void ChangeMoveSpeed(float amount) { moveSpeed = amount; }

then your Inputs or anything can change it by just calling that method, the movement script shouldn't care where from, it only cares it needs to change movement speed and handle movement code

#

you can make the value public but then you can't know for sure it was changed, and most times you do to react elsewhere based on it

misty sand
#

hello all, i want to make a manual blinking mechanic in my game. if you dont blink after a certain time an image (most likely going to be what it looks like when your eyes water up a lot) will slowly gain opacity until at 100%. how im thinking i would need to do it is having a a timer and a blink length variable where on a keypress a black image(blink) will be unhidden and rehidden for a second and restart the timer. if the timer hits the blink length (how long the player can go without blinking) the images opacity will go up at a fixed rate. im not sure how I would set this up though, especially the image opacity part any advice?

#

oh hi @rich adder

rich adder
misty sand
rich adder
#

true but the logic is similar

#

most of these systems are easily repeated but applied in diff context

misty sand
#

my main worry is with increasing the image opacity

rich adder
#

the opacity thing can also be handled pretty easy,

 void SetEyeStrainAlpha(float alpha){
        Color c = eyeStrainImage.color;
        c.a = alpha;
        eyeStrainImage.color = c;
    }```
misty sand
#

oh

#

so all in all this should be a pretty simple script

rich adder
#

how you map it based on value is up to you , plenty of ways .. Linear, Curve, etc

rich adder
#

if Blink() method is called, reset the timeSinceBlink, SetEyeStrainAlpha(0) etc.

#

you need two timers or use timer + coroutine

misty sand
#

@rich adder do you mind if you explain the opacity thing again, this is what i have so far, ```using Microsoft.Unity.VisualStudio.Editor;
using UnityEngine;

public class BlinkScript : MonoBehaviour
{
public Animator anim;
public float nowTime;
public float MaxBlink = 5.0f;
public Image DarkEyes;

// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
   
}

// Update is called once per frame
void Update()
{
    nowTime += Time.deltaTime;
    if (Input.GetKeyDown(KeyCode.E))
    anim.SetTrigger("blink");

    
        if(nowTime >= MaxBlink)
    {
        
    }

}

}

grand snow
#

whats the goal, to animate in and out some ui image?

#

oh right some thing slowly appears if you dont blink

rich adder
# misty sand <@968604165150507078> do you mind if you explain the opacity thing again, this i...

I would do something like this

float deltaTime = Time.deltaTime;
        timeSinceBlink += deltaTime;
        if (timeSinceBlink > maxBlinkTime){
            float excess = timeSinceBlink - maxBlinkTime;
            float alpha = Mathf.Clamp01(excess * opacityIncreaseRate);
            SetEyeStrainAlpha(alpha);
        }
        if (isBlinking){
            blinkTimer -= deltaTime;
            if (blinkTimer <= 0f)
            {
                isBlinking = false;
                blinkImage.gameObject.SetActive(false);
            }
        }```
#

then onyour keypress call StartBlink or something to reset the values and show blink image

gentle trellis
#

how do I fix it, what did I do wrong

slender nymph
#

you probably want the URP bloom type

gentle trellis
#

thanks

elfin dew
teal viper
#

!ask

radiant voidBOT
# teal viper !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

warped sierra
molten otter
#

is there a way to make sure the physics engine moves a rigidbody an exact amount per fixed update? I'm using ECS physics if it matters

#

I thought a rigidbody would be moved by its velocity * FixedDeltaTime every fixed update but it doesn't seem to be the case

#

maybe there's something else wrong though

warped sierra
quiet pollen
#

I have both a collider and trigger (2d) on a bullet object, but when it gets shot it immediately hits the player because self damage is on, how can I make it so that the trigger is off really quickly before turning on

teal viper
rich adder
quiet pollen
#

thank you

quiet pollen
#
healthbar.fillAmount = Mathf.Clamp(currentHealth / maxHealth, 0f, maxHealth);
#

this isnt working, I think due to current and max health being ints

#

but like... I have no clue how to fix it

slender nymph
#

if they are ints then that division can only ever result in an int. you need to cast one of them to float if you want to get a float

quiet pollen
#

I fixed it thank you

molten otter
#

when I turned it off I started getting expected results with a small margin of error

#

I do want interpolation to be on, but I want to get the rigidbody's actual position instead of the interpolated position. I'll probably ask around in #1062393052863414313 tomorrow 👍

marsh raft
#

i am a final year student at a university in VietNam, majoring in game programing , and I have been studying unity for three years. At the moment, i want to improve my English.I'm looking for someone to exchange knowledge with me: i will explain what i know about unity and game programing in return, you can help me improve my English

quiet pollen
#
 public EnemyScript[] Enemy;

 private IObjectPool<EnemyScript> objectPool;

 [SerializeField] private bool collectionCheck = true;

 [SerializeField] private int defaultCapacity = 20;
 [SerializeField] private int maxSize = 100;

 public GameObject BulletStorage;



 private void Awake()
 {
     objectPool = new ObjectPool<EnemyScript>(CreateProjectile, OnGetFromPool,
         OnReleaseToPool, OnDestroyPooledObject, collectionCheck, defaultCapacity, maxSize);

 }

this is what I have for my pooling script rn, but it cant accept EnemyScript[] bc its an array of scripts and I dont think I actually know how arrays work bc im dumb, please help

marsh raft
# quiet pollen ``` public EnemyScript[] Enemy; private IObjectPool<EnemyScript> objectPool; ...

Object Pooling is a design pattern that belongs to the creational category. It helps optimize object reuse, which reduces pressure on RAM (used for storage), the CPU (used for logic processing), and the GPU (used for rendering graphics).

However, the main challenge lies in managing object properties: how to make a reused object behave like a brand-new one. If you apply this technique without truly understanding how it works, it is honestly a bad practice.

You should first get comfortable with the basics, such as arrays or lists, by doing simple exercises—for example, creating a list of enemies and spawning them gradually. After you clearly understand how things work, only then should you consider using the Object Pooling pattern.

quiet pollen
#

yeah you're probably right lol

keen dew
#

Thanks ChatGPT

marsh raft
#

Actually, it was my own idea, and I only asked ChatGPT to translate it into English because my English is not very good.

sour fulcrum
#

please state when ai is used

#

answering with ai (even with translation) without specifying is against the rules here

marsh raft
#

Yes, I will keep that in mind. Thank you for the reminder.

quiet pollen
#

I figured it out I should be able to pool any enemy now

#

so thats great

#

is the easiest way to load them all into a pool to just get and then return them

#

on game load

#

idk how else I would do it

marsh raft
# quiet pollen I figured it out I *should* be able to pool any enemy now

That sounds great, but there is an important note to keep in mind. When you use this technique, there are two key points you must pay attention to. First, you need to properly reset or adjust the data when the object is being reused. Second, you must clean it up after it has finished being used. This technique becomes extremely complex if the objects you want to reuse have complicated structures and behaviors. This is genuinely based on my experience from a course project I worked on during my second year at university.

quiet pollen
#

yeah I should be able to do that stuff pretty easily I think hopefully

wild cove
#

Hey, I want to make a script that involves multiple factors, like deleting a ton of things and resetting the players score to 0 in an endless runner when they collide with things. But all my scripts are monobehaviour and I don't know how to change all these factors at once. Should I combine all of them into a monobehaviour script or do i need to make a new blank script (I did try this once, but I wasn't sure if I needed to do it and quickly became confused with what I was doing)?

hoary nova
# rich adder ```cs if (!upgrades[random].stackable) { upgrades.Remove(upgrades[random]); ...

all this line of code does is remove any none stackable upgrades from the list after them being used, and this is not the line of code that ois annoying me, it works just fine !

if (randomSO.requiresUnlock)
{
if (!abilitiesOBJ[random].GetComponent<Abilities>().unlocked)
{
return getRandomSO(); <--- this is what bugs me, ha, get it? because it "bugs" me and its a bug? okay I will shut up
}
}

when the code does the "return getRandomSO();" bit, instead of redoing the function again until it finds something that is unlocked, it just returns null

dark hatch
#

hi, i have an object teleporting (by setting position via script) into a collider with a trigger but the trigger doesnt activate. any way to do this? (2d)

ivory bobcat
#

You'd want to do so after teleportingcs transform.position = ...; Physics.SyncTransforms();//has some expense

#

If you're teleporting a lot of objects, do so after teleporting every object.

flat gorge
#

yo guys i have no expierence with code and i wanna get started with unity. what should i do and if anyone can help me code it will be very appreciated

ivory bobcat
#

!learn

radiant voidBOT
gloomy bison
#

(just a suggestion)

flat gorge
#

doesent unity use C# though

gloomy bison
#

ti does

#

learning the fundementals of c# first would help drastically

flat gorge
#

where do i go

gloomy bison
#

or you'd be in a position i am atm trying to make an inventory system with an array and struggling

gloomy bison
#

it would help a lot

flat gorge
#

k ty

gloomy bison
# flat gorge k ty

you can also find tutorials online and/or w3schools website. they're all good for teaching the fundementals of programming

#

i wish you good luck on your journey

flat gorge
#

ok

#

do you have any reccomandations for tutorials

gloomy bison
# flat gorge do you have any reccomandations for tutorials

codemonkey and brackeys are good. however, tutorials tends to be mindlessly following instructions and not properly learning in most cases. i'd say reading doccuments and following along and understanding what the code does first before being able to implement it properly

flat gorge
#

ok im doing unity learn

#

thank you

#

@gloomy bison what unity version should i start on I have 2022 but the docs u gave me (unity learn) says to use latest version

naive pawn
#

(cc @dark hatch ^)

naive pawn
harsh tartan
#

does anyone knows a good video to learn how to make an inventory?

naive pawn
hoary nova
naive pawn
#

let me guess, you were getting an error about null, not null as the result

rain quartz
#

HI all, New developer here. Hitting 40 im a little late to the game so to speak. Trying to get started as a hobby. I can see quite a few people having this issue around Mouse Look not working. I've exhausted all posibilites and im worried ive just been staring at the answer and missing it. Can anyone help ?

naive pawn
#

!ask

radiant voidBOT
# naive pawn !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

visual idol
#

I really don't know what to do anymore. I can't talk to my NPCs anymore and I always get a "null frenc" response, and I just don't know what to do anymore. I'm totally desperate. I just want my quest to work.

naive pawn
#

what do you mean by "null frenc"?

#

are you getting errors?

cosmic dagger
visual idol
#

mom pleas

cinder schooner
visual idol
#

o you mean that you receive a null reference error? If so, can you post the error along with the script?

#

The null reference error is gone.

naive pawn
#

we're asking about your issue

#

what is the issue you're having

#

!ask

radiant voidBOT
# naive pawn !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

naive pawn
#

no-one can help if we don't know what you need help with

visual idol
#

No, I speak German, bro, and my Greek isn't that good.

naive pawn
#

what's greek got to do with this

pure pine
naive pawn
#

@visual idol do you have a question or issue you need help with or not?

cinder schooner
#

lol

cinder schooner
naive pawn
#

please do not spam, this isn't a social space

rain quartz
naive pawn
#

also, don't multiply mouse delta with delta time, it's already per frame

frail gust
#

Hi i downloaded unity recently because i wanted to start creating a video game but i dont know where to start can y'all give me some advice?

naive pawn
#

!learn

radiant voidBOT
naive pawn
#

start there ^

low copper
#

I need to json encode/decode dictionaries. Based on my research it seems like I should be using com.unity.nuget.newtonsoft-json. Figured I would check in here before implementing. Any issues with it? System.Text.Json seems like its better but not supported (at least as easily).

runic lance
grand snow
#

json.net is good reliable choice and is probably already added as a package in your project rn

low copper
#

Ok. Thanks. You guys see, that the package manager has some sort of invalid signature bug happening to all the packages? NBD...they know about/working on it but figured I would mention it.

#

@grand snow : yep you were right...already installed

low copper
#

Hmmm...would that prevent the package from being available in my project? I'm getting "The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)" even though the package is in my package manager "In Project" list and I can locate it in the Packages folder

grand snow
low copper
#

Sorry I don't know what that means....I have the following at the top of my file "
using Newtonsoft.Json;" and then I am using it as "saveData = JsonConvert.DeserializeObject<SaveData>(jsonString);" but it says the error I provided earlier and "The name 'JsonConvert' does not exist in the current context"

grand snow
#

Is your ide happy with this code?

#

If this code is in a assembly definition then you must add the ref yourself.
If not then the automatic Assembly-Csharp asm references everything for you

low copper
#

ide is producing the errors I provided

#

google is not helping me figure out how to fix this

grand snow
#

you have 0 compile errors in unity so it may be working and your ide is lying to you

#

Save the changes and go check

low copper
#

Hmmm...this is the first time that has happened to me. Ok, let see how it goes

gloomy bison
#

i have a question about raycasting;
my raycast always goes out but:
A. Doesn't show the debug line when I use it
B. Doesn't recognise at least one of my objects.

As shown in the images, they're all on the PickUp layer with the "PickUp" tag.
And as shown in the code block below, this is the code i'm using.
My main problem: The object named "Hammer" does not get registered by the raycast. Am I doing something wrong?

(UNITY VERSION: 6.3 (6000.3.2f1)

// In update function
 // Check for player input [E KEY]
 if (Input.GetKeyDown(KeyCode.E))
 {
     Debug.Log("REGISTER_E");
     // Raycast for object detection
     RaycastHit hit;
     Vector3 forward = transform.TransformDirection(Vector3.forward);

     if (Physics.Raycast(transform.position, forward, out hit, rayDist, objectsLayer))
     {
         Debug.DrawRay(transform.position, transform.forward);
         Debug.Log(hit.collider.name);
         // If object, check inventory space
         if (hit.collider.CompareTag("PickUp"))
         {
            for(int i = 0; i < objectsInInventory.Length; i++)
            {
                 // If space, add object. If no space, don't
                 if (objectsInInventory[i] == null)
                 {
                     objectsInInventory[i] = hit.collider.gameObject;
                     break;
                 }
            }
         }

     }


 }

(what I want the code to do)
I want the code to get the gameobject and stick it in the next available inventory space. Idk if my raycast is wrong.
Any help will be appreciated.
Thank you in advance!

#

Also, it outputs the names of everything else apart from the Hammer

blazing mural
#

can someone help me with this

gloomy bison
gloomy bison
# blazing mural

looked this up on google rq
stackoverflow answer: "Actually I solve this problem by adding the modules (Android SDK & NDK Tools, OpenJDK) to my Unity Editor. Actually if you tick the Android build support module, it won't automatically help you to tick the two modules above."
edit: ref - https://stackoverflow.com/questions/61865817/jdk-directory-is-not-set-or-invalid-unity

#

in the UHUB, go to installs > manage > modules then it should be there

lunar lotus
#

whats wrong there ?

rich adder
radiant voidBOT
#
<:error:1413114584763596884> Command not found

There's no command called screensjpts.

#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

rich adder
#

also you need to configure your IDE

frail hawk
#

it seems like you have to fix your IDE, you dont have auto code complete

#

@lunar lotus

thorn trout
#

Can i not use GetAxis like this? Im getting an error

lunar lotus
#

it is the first time i use visual studio code

naive pawn
naive pawn
#

!ide

radiant voidBOT
rich adder
thorn trout
rich adder
#

follow the one for VSC

naive pawn
# thorn trout

check the stacktrace maybe, it sounds like you're calling it from somewhere you shouldn't

#

but first, configure your ide

rich adder
thorn trout
#

countless times

thorn trout
lunar lotus
rich adder
lunar lotus
#

how to turn on auto code complete

rich adder
lunar lotus
#

i installed the unity extension and put the external script editor to vsc

frail hawk
#

you still dont have intellisense working right

#

try restarting both , Unity and the IDE

swift crag
#

if you did, then close VSCode and regenerate project files in Unity (in your Preferences menu, go to External Tools, then hit the button)

blazing mural
#

chat am i cooked?

cosmic quail
split stirrup
#

Hi, how can I fix this?

wintry quarry
split stirrup
#

thanks

wintry quarry
#

for now just ignore it

scarlet tinsel
#

Hello, I'm on a fresh project with Unity 6000.3.5f1 to demonstrate an error I've been getting for the past few days.
I merely want to build one of my game projects (built on android,) and I've received the exact same error on every single unity project on Unity 6 as a whole right now.

I've tried anything and everything I could to no avail, and I promise you, whatever you'll ask if I did, I most definitely have tried.
Please help me, what do I do 😭

grand snow
scarlet tinsel
#

Everything is the included ones.

grand snow
scarlet tinsel
#

I've done that multiple times already on multiple different test projects.

grand snow
#

Whole Library/ folder too?
May be that you need to re install this editor version or try using android sdk + ndk from android studio

scarlet tinsel
#

Yeah, whole thing. I've tried to reinstall this editor twice aswell. I've tried to install other sdks and ndks but Unity complains that it either can't find it, or its invalid...when its not.

grand snow
#

If done via android studio you have to set the custom path yourself but it will work

#

just make note of where android studio installs these

scarlet tinsel
#

I haven't tried directly using Android Studio, that may be a fault? I'll try that now.

grand snow
scarlet tinsel
#

Am I dumb for getting confused with Androids site and downloads? lol

#

Got it though

buoyant wasp
#

hey anyone know why I have this error?

limber willow
#

There is a bug listing packages as not safe, i think they are working on it. I believe i saw that on their website

buoyant wasp
#

I deleted 65 of projects and hub and application itself Also restarted my licence but never fixed

limber willow
#

afaik

#

i have the same issue

hexed terrace
buoyant wasp
#

I see

summer dragon
#

does anyone know any app or good tutorial for c# on unity?

thanks!

hexed terrace
#

!learn

radiant voidBOT
hexed terrace
#

☝️ there and see the pinned msgs of this chan

summer dragon
#

thanks

hexed terrace
#

all the chans on this server have pinned msgs to relevant tuts/ help/ etc

lethal meadow
#

Is this the channel for shader issues

scarlet tinsel
lethal meadow
#

ty

#

!code

radiant voidBOT
grand snow
scarlet tinsel
#

It happened for me on 6000.3.3f1 aswell

grand snow
#

Got enough disk space? no anti virus fuckery?

scarlet tinsel
#

Over 100 gigs should be freely available, and my antivirus hasn't NOTIFIED me of anything... should I try to disable it?

misty sand
#

@NAV

#

@rich adder

#

hey

#

how do you suggest i add a random timer so that after a random amount of time an audio source is played

grand snow
#

why ping him

misty sand
#

cus he said to ping him if i have any more questions

scarlet tinsel
grand snow
misty sand
#

how would i use a wait for seconds function but have it wait for a random number between two numbers?

scarlet tinsel
#

Nope

grand snow
#

get a random value in that range, then use that as the wait seconds...

rich adder
misty sand
#

mb lol

rich adder
#

plenty of knowledgable people here ready to help out

misty sand
#

facts

rich adder
#

but yeah the Random class will be your best bet here, Range is the function you'd want

#

keep in mind If you have a System namespace and UnityEngine in your script the computer going to be confused though to which Random class you want to use because they both have it. You have to tell it either with a fully qualified namespace UnityEngine.Random.Range(etc.. or using Random = UnityEngine.Random at the top

scarlet tinsel
grand snow
#

The default "personal" folder may use onedrive because microslop are bastards
Your user folder (users/me) is safe

scarlet tinsel
#

yeah users/me

#

I hate those personal folders being onedrive lol

grand snow
#

Then im out of ideas 😭

scarlet tinsel
#

Yeah I tried all kinds of things but

#

I managed to get it to build yesterday by forcing the missing values inside of the file while it was building, but the app wouldn't open because it was trying to access memory it 'wasn't given permission for'

#

So, that clearly doesn't work.

#

And Unity 6 is broken for me as a whole.

#

I'd use a previous version thats functional, but I specifically need android r27c which unity is very stingy about changing the version you're hooked up to

grand snow
#

seg fault? probably due to a null pointer deref from what you tried to make work.
If that file is just missing or empty then its clear something is wrong with the compilation output

scarlet tinsel
#

The file isn't missing nor empty, it just has 5 values completely not included.

misty sand
#
    {
        yield return new WaitForSeconds(Random.Range(1, 3));
        Debug.Log("whisper");
        source.PlayOneShot(whisper);

    }``` im probably being dumb but this isnt playing a noise or running the message in the console
rich adder
#

also keep in mind you are using the int version of the Range so its gonna be either 1 or 2 secs exactly, nothing between 1f and 3f , no decimals. The int version is max exclusive so its not going to include 3

grand snow
scarlet tinsel
#

Maybe I can try the LTS for 6.0?

grand snow
#

May be better but would require downgrading so ensure you have backups if not using source control

scarlet tinsel
#

Yeah, I got backups.

#

Huh, I just tried to build a 2022 project and it errored out with a different error.
Maybe I am just destined to never make games again lol

green snow
#

Hi

#

Guys im having an issue whenever i yry to install unity it says validation failed

rich adder
#

also check the logs and see what they say

green snow
#

Oh it got fixed nvm

misty sand
#

uncs tweaking

cerulean shuttle
#

guys Im totally new to game dev, whats the easier engine? unity or sbox?

grand snow
#

I may be biased but unity
sbox is incomplete and has many unknowns

cerulean shuttle
#

I think I’ll just try to make a pong in both

#

I’d like everyone’s opinion. Which of these game concepts do you think would perform better? in terms of player interest and reception.

1.    A hardcore tactical fps with small maps like csgo, proximity chat, movement mechanics etc.
2.    A survival horror game focused on managing bunker systems and machinery.
3.    A story game with PS2-style graphics set in soviet/industrial city.
misty sand
#

if your new to game dev the first option definitely seems ambitious

eager stratus
#

So how do I accomplish this with the new input system?

{
    if (Input.GetMouseButtonDown(1))
    {

    }
}```
eager stratus
grand snow
#

but yea reading from the device directly still works

eager stratus
#

Or at least the current instance of it

pastel cave
#

I have two gamepad-controlled players, but for... whatever reason, they Start() before my two players that are on the keyboard, which causes those to players to attempt to consume the keyboard scheme

#

I can force the keyboard players back to keyboard, but I don't know of a way to force players into a...

#

a state in which they are polling for unpaired devices

steady isle
#

where do i paste my code if i wanna send large code

#

nvnm

young sapphire
#

How to make a flight controller

wintry quarry
#

That's too vague/ simple a question for someone to answer

#

the simple answer is - write a script

pale galleon
#

I am making a unity paddle game as my project:

I have coded the lock range of the paddle so it does not go above the screen, but I am having problem the ball being on the middle of the paddle to stay there and move with the paddle as I move it right to left and keep the ball centered and on top of the paddle and move with the paddle as the paddle move right to left. Like the paddle is carrying the ball:

        transform.position = new Vector3(Mathf.Clamp(Input.GetAxis("Horizontal") * speed * Time.deltaTime + transform.position.x,-10,10),
                                             transform.position.y,
                                             transform.position.z);
       ball.transform.position = new Vector3(Input.GetAxis("Horizontal") * speed * Time.deltaTime+ball.transform.position.x,
                                             ball.transform.position.y,
                                             ball.transform.position.z);

This is the code. Any help would be greatly appreciate it.

wintry quarry
#

but also - your code is essentially moving both objects with the same code

#

so it makes sense they move together, no?
both objects are getting Mathf.Clamp(Input.GetAxis("Horizontal") * speed * Time.deltaTime added to their position, identically

dapper flame
#

When I did this same project (in 2d not 3d) I used Box colliders to stop the paddle and the ball, not the code.

pale galleon
#

OK

#

that is the full script

#

that is in the playercontroller script

#

So, if I just did one line the type line and deleted the ball.transform..only the paddle moves and the ball fall on the ground. At the start of the game the ball is positioned on top of the paddle.

pale galleon
#

So naturally I have to put the script of the ball on the same script as the playercontroller.

wintry quarry
#

what are you actually trying to do here?

wintry quarry
#

there is an entire universe of options here

#

how do you want it to work?

naive pawn
pale galleon
#

ok...agreed..the ball should not respect gravity undersood.

wintry quarry
#

also if these objects are physics objects - that is - with colliders, they should not be moving via the Transform at all

pale galleon
#

@wintry quarry I want when the ball ands on teh paddle it stays on the paddle and when the paddle moves it carries the ball with it

naive pawn
#

you don't want it to bounce?

pale galleon
#

of course

wintry quarry
pale galleon
#

but at the beginning of the game it stays on the paddle and once you press space it bounces

naive pawn
pale galleon
#

OK

#

when you start the game it stuck on the paddle at the beginning of the game

#

as soon as you press space it bounces on the paddle

pale galleon
#

how do I do that?

wintry quarry
#

and set any Rigidbody it may have to kinematic

#

(assuming it has one)

#

and disable any other movement script it may have

pale galleon
#

@wintry quarry you said they should not be moving with transform, if they have collider how should they be moving?

pale galleon
#

OOOH

#

rigidbody?

wintry quarry
#

yes

pale galleon
#

like this?

#

then I use getcomponent regidbody of the ball?

#

It worked! So when I press space ....with proper code I can make the ball bounce around, even on the paddle itself?

teal elk
#

I cant get my projectile to interact with the ground, even though it set it in the collision matrix

 void Update()
 {
     transform.position += -transform.up * projectileSpeed * Time.deltaTime;
 }


 private void OnCollisionEnter2D(Collision2D collision)
 {

     //if (IsRelease) return;

     //if (collision.gameObject.TryGetComponent(out JetpackController jetpackController))
     //{
     //    return;
     //}

     if (collision.gameObject.TryGetComponent(out Ground ground))
     {
         explosionParticle.Play();
         StartCoroutine(ReleaseProjectileToPool(0.5f));

         Debug.Log("Hit");
     }
 }

The Debug message never triggers

slender nymph
teal elk
coarse swallow
#

im trying to fix the movement for moving on this directional gravity circle (like a planet). right now when i try to jump on it, the player only goes up. How do i make it so that the player can jump perpendicular relative to which part of the circle you are on (e.g if you are on the bottom, jumping sends you down.)

keen dew
#

Have you confirmed that the raycast hit anything

naive pawn
#

you'd probably want to raycast to the feet of the player, not down

#

if you were on the underside of the planet, that'd be casting away from the planet

#

though actually - that would kinda require already knowing the direction to be able to set the feet in the right direction, wouldn't you want to get a direction vector directly to the planet or something like that?

coarse swallow
#

well cos theres multiple planets. like you would jump from 1 planet's attraction layer to the next.