#💻┃code-beginner

1 messages · Page 718 of 1

vital vault
#

the thing is i want to check if player has collisions with anything, and if i will just raycast towards object on the map it will be wrong like 99% of the time

#

because bap has some... curved thingies

rough granite
#

bap? curved thingies?

vital vault
#

typo sorry

#

and lemme send screenshot

rough granite
#

if you are raycasting from the rigidbody directly to the collision why would something be in it's path?

vital vault
#

because i would prob raycast from player feet towards object

rough granite
#

use a layer mask

vital vault
#

i cant just "remove" it

rough granite
#

huh?

vital vault
#

i need slopes like that

#

and if i will make it incollideable it will be wrong

rough granite
#

huh?

smoky ruin
vital vault
rough granite
#

no i need you to im lost on what you are getting at

vital vault
#

lemme show in editor

#

even worse

#

i made a map 1 obj file

rough granite
#

i've got no clue at what i am meant to be looking at

vital vault
#

on the right its origin

#

so in that case i wont be able to get its normal via raycast

rough granite
#

if you are trying to get the normal of something that is expected to always be below you why not just send the raycast down?

vital vault
#

i dont except for it to be below

rough granite
#

nothing is stopping you from getting collisions what

vital vault
rough granite
#

you mentioned this is to be from the feet, and you mentioned slopes so why would the raycast go any other way but down?

vital vault
#

i need its normal

rough granite
#

right you get that with the fucking raycast

#

or this, not that i would recommend this way since it's based off the first contact which could be off
ContactPoint contact = collision.contacts[0];

    // Rotate the object so that the y-axis faces along the normal of the surface
    Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal);
#

which is shown in that link i sent, read.

vital vault
#

srry

#

but one more question: how to check collision in update

rough granite
#

you dont

#

unless you make a instance variable but then even after you aren't touching the object it'll still be set as that collision

vital vault
rough granite
#

cause OnCollisionEnter is called when a collision is detected it has no relation to Update();

vital vault
rough granite
#

you dont what?

vital vault
#

otherwise there will be some bugs when 2 objects touch player at the same time

rough granite
vital vault
vital vault
#

But if it equals zero, it will do the same equation but instead of dot product it will put deltatime

#

So that results in a really funny controller that allows you to climb, slopeboost, etc

#

And also those features were a result of a bug

vital vault
rocky canyon
#

i would think that odds are u wouldnt get two OnCollisions at the exact same frame..

#

soo maybe use like a cooldown timer after that first collision to not the code to run again for X amount of seconds or something

#

also "states" come to mind.. if ur in this state allow this.. if ur in that state dont allow this.. etc

vital vault
#

Thats why

#

And i asked because you can stand on the floor, bump into corner and get even 3 collisions

toxic crypt
#

is there any way to delete all the players in unity cloud the easy way?

rich adder
#

I have a small client to facilitate such things, if you're still interested I can send it to you (when its done)

#

kinda sad that after many posts I made on forums the current web interface is pretty underwhelming with missing features requested long ago

toxic crypt
#

can you send me code ? I'll add it to my game's admin panel

#

or api

#

oh nice found it
DeleteAccountAsync()

rocky canyon
#

checkin for collisions every single update frame would be hella expensive
thats y collisions/physics happen in fixedupdate (which is a slower but fixed frame)
physics can be accurate b/c of it having that fixed timestep..

you could change the physics step in the settings to match the Update() if you also locked your framerate.. but thats just silly
so now im also assumin this is an x/y problem and what u think u should have happen doesn't actually work that way.. and(or) theres a more simple standard solution to ur problem

i also misunderstood what u were asking originally mb

rich adder
smoky ruin
#

I found out why the speed is being reduced

vital vault
smoky ruin
#

I didn't really understand why, but I know it's because of this

rich adder
vital vault
#

And if that delay would happen on jumps many frustration would appear

smoky ruin
sturdy vigil
#

My first mesh 😛

#

I dont really know why the texture dont fit all the mesh, the image is only the apple :c

left sail
#

Hi, I'm trying to make sure that my wheels have a rotation but nothing did, the front vehicle backs up etc but the visual physics doesn't work

white girder
#

And what is car controller doing UnityChanHuh

white girder
sturdy vigil
#

Now my mesh and texture are working 👏👏

cosmic grotto
#

Hi I am I right in thinking with cinemachine i do not need to attached a script to the main camera. Could I ask with cinemachine how do I fine out what the issue is or can I add script to the cinemachine. I have checked and I am following the correct target because the cinemachine rotates and looks where the object is going but does not follow it.

eternal needle
wet meteor
#

i cant find a way to make an rocket launcher does someone know how?

low goblet
#

is there any other way to prevent

No measure function set in this node's config
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

spam in 6000.2 besides restarting the editor?

rich adder
wet meteor
#

now i lost all the codes due to a mistake lol

low goblet
wet meteor
rich adder
wet meteor
#

i had 0 errors when i checked

#

maybe it was a bug or sm

#

im just gonna try an other way of making it

low goblet
wet meteor
#

ohh ye

thorny void
#

!code

eternal falconBOT
naive pawn
eternal falconBOT
left sail
celest pond
#

can anyone help me please: What is wrong with this (its the newest Unity Version)

#

private IEnumerator DarknessEvent()
{
Light[] sceneLights = FindObjectsByType<Light>();
float duration = 10f;
float elapsed = 0f;

 foreach (var light in sceneLights)
     light.intensity = 0f;

 while (elapsed < duration)
 {
     float randomTime = Random.Range(0.1f, 0.5f);
     yield return new WaitForSeconds(randomTime);
     if (sceneLights.Length > 0)
     {
         Light l = sceneLights[Random.Range(0, sceneLights.Length)];
         float originalIntensity = l.intensity;
         l.intensity = 1.5f;
         yield return new WaitForSeconds(0.1f);
         l.intensity = 0f;
     }

     elapsed += randomTime;
 }

}

sour fulcrum
#

whats wrong with it

celest pond
#

It cant find the lights

grand snow
#

use a serialized list instead?

sour fulcrum
#

what does that mean

celest pond
#

Wait, I am stupid, they are 2d lights

grand snow
#

Ha well good you realised

#

use a serialized list/array if you like performance

celest pond
naive pawn
left sail
naive pawn
#

so what was the issue again?

hollow spruce
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PlayerMovement : MonoBehaviour
{
    public float moveSpeed = 5f;
    public float jumpForce = 10f;
    public bool canJump = false;
    public bool canClimb = false;
    private Vector2 movement;
    private Rigidbody2D rb;
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }
    void Update()
    {
        movement.x = Input.GetAxisRaw("Horizontal");

        if (canClimb){
            movement.y = Input.GetAxisRaw("Vertical");
        }

        if (Input.GetButtonDown("Jump") && canJump){
            Vector2 jumpVector = new Vector2(0, jumpForce);
            rb.AddForce(jumpVector, ForceMode2D.Impulse);
        }
    }

    void FixedUpdate()
    {
        if (!canClimb){
            rb.velocity = new Vector2(movement.x * moveSpeed, rb.velocity.y);
        }
        else {
            rb.velocity = new Vector2(movement.x * moveSpeed, movement.y * moveSpeed);
        }
    }

    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("Ground")){
            canJump = true;
        }
        else if (other.gameObject.CompareTag("Death")){
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
        else if (other.gameObject.CompareTag("Ladder")){
            rb.gravityScale = 0;
            rb.material.Friction = 10;
        }
    }

    void OnCollisionExit2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("Ground")){
            canJump = false;
        }
        else if (other.gameObject.CompareTag("Ladder")){
            rb.gravityScale = 8;
            rb.material.Friction = 0;
        }
    }
}

why i can't change the rb.material ? it's a physical material

sour fulcrum
#

rigidbodies don't have materials

grand snow
#

they have physics materials

sour fulcrum
#

colliders do

grand snow
#

oh right, so the problem is "my code doesnt compile"? or what

sour fulcrum
#

im guessing yeah

#

since rb.material is not valid

hollow spruce
#

so what to do

sour fulcrum
#

what have you tried to do so far

hollow spruce
#

only this

#

then i got stuck

grand snow
#

was this ai generated or you just tried to guess what to do?

sour fulcrum
#

what have you tried to do to solve the problem*

subtle bane
#

Can i Say that cursor and other similar AI assisted code creations tools are so nice tò have in 2025 i can code much more and much faster than i ever could even if i was a senior

sour fulcrum
#

You can absolutely say it!

#

It's not true but you can say it

frosty hound
subtle bane
#

Nice ok, Sorry i didnt know there was a thread about It, thx

tiny crag
#

hello is there a way to detect collisions without making the object push eachother?

subtle bane
#

Kinematic rigid body ig?

tiny crag
#

no then they wont detect collisions they have to be dynamic apparently

tiny crag
rich adder
#

"detect collisions" is pretty vague. what are you trying to do

tiny crag
#

its between two objects and i only want the collision to be detected, not for them to push eachother

rocky canyon
#

use trigger colliders?

subtle bane
#

Trigger colliders should do the trick

tiny crag
#

alr ima look into what trigger colliders are

subtle bane
#

Just a check on the collider

tiny crag
#

thanks!!

subtle bane
#

Trigger on Collider should be checked

tiny crag
stuck current
#

Where can I find games that I can access the editor and dive in and see how things work

sour fulcrum
#

theres some open source projects but not like fully finished notable ones

rocky canyon
subtle bane
tiny crag
#

!code

eternal falconBOT
tiny crag
#

there isnt a channel for bot commands right?

naive pawn
#

there isn't, no

slender nymph
#

would be a bit pointless since the commands are meant to direct other people to resources

tiny crag
#

ok just wanted to be sure

#

anyway collisions are not being detected now that i changed to trigger colliders

#

on row 39

slender nymph
naive pawn
tiny crag
#

yes but isnt it supposed to realize that it has been triggered when the collider makes contact with another game object?

slender nymph
#

have you gone through the steps in the link i posted

vital vault
#

why do this code

_rb.MoveRotation(Quaternion.Euler(0, Input.GetAxisRaw("Mouse X")*_sensitivity*Time.deltaTime, 0));

rotates my player around X axis, not Y?

naive pawn
#

oh it's a trigger message

naive pawn
tiny crag
slender nymph
naive pawn
#

that's very little info to go off of

vital vault
naive pawn
slender nymph
naive pawn
#

imma just be blunt, you're probably reading it wrong

vital vault
naive pawn
#

also note that that's basically an assignment - "set the rotation to X" rather than "rotate by X"

slender nymph
#

use mp4 not mkv to embed in discord

vital vault
patent wedge
#

whats the best way to get* different values based on if it's left, top left, right etc. i.e left = 0 topleft 1. need need the value to lerp between each other too.

vital vault
rich adder
#

get values from where?

naive pawn
#

it sounds like you're asking about representing directions

#

in which case, well, direction vectors?

patent wedge
rich adder
#

so Inputs ?

patent wedge
rich adder
vital vault
patent wedge
rich adder
naive pawn
tiny crag
#

@slender nymph i went through the steps and i still cant understand why it isnt working

vital vault
#

i call it in update

slender nymph
patent wedge
slender nymph
tiny crag
rich adder
vital vault
patent wedge
naive pawn
slender nymph
tiny crag
#

@slender nymph omg i forgot to turn on is trigger on the enemy prefab

#

thanks mate

naive pawn
slender nymph
naive pawn
#

but that would have a jump when it goes 360°

naive pawn
rich adder
tiny crag
patent wedge
vital vault
#

and still, player doesnt rotate but instead just doing flips

#

!code

eternal falconBOT
rich adder
vital vault
rich adder
#

pass the V2 and get some values

vital vault
naive pawn
naive pawn
rich adder
naive pawn
#

a direction taken from joystick input

rich adder
#

yeah thinking some type of mapping

patent wedge
rich adder
slender nymph
slender nymph
#

Well you forgot to look at the only lines of code that actually do rotate things around the X axis

rich adder
#

"Moves the kinematic Rigidbody towards position."

#

anything Physics related should also be in FixedUpdate

rocky heart
#

guys i use Destroy(gameObject); and some objects wprk but others say Destroying assets is not permitted to avoid data loss

rich adder
rocky heart
#

huh

#

like i just instantiate a prefab and the instance tries to destroy itself but it gives the rror message how do i delete the instance

keen dew
rocky heart
#

bro its just like 3 lines

rich adder
#

you are probably not deleting the instance / running the code off the prefab

rocky heart
#

why would i post the whole code

keen dew
#

Because we can't tell what's wrong with your code without seeing it

rich adder
rocky heart
#

ok rude

keen dew
#

You're trying to destroy a prefab. Why and how? We can't tell without seeing the code

ivory bobcat
#

The unwanted behavior probably is related to the other lines of code

vital vault
#

whats called first: oncollisionstay or update?

sour fulcrum
#

generally oncollisionstay

#

but it depends

sour fulcrum
rocky heart
ivory bobcat
#

How to post !code

eternal falconBOT
rich adder
#

sorry its early morn for me lol my brain still not functioning

naive pawn
sour fulcrum
#

like if you ran Physics.SyncTransforms()

#

or do those still get delayed

naive pawn
#

oncollisionstay is called in the fixed time step
update is called per frame

rocky canyon
#

ya, i said this yesterday.. they're confusing how collisions occur..

#

they were wanting every frame collisions yesterday iirc

#

xy

sour fulcrum
#

oh lord

keen dew
vital vault
rich adder
#

btw like most things, you can easily test this with some logs

#

isn't that the whole point of development too ? trial and error to see how results play out

rocky heart
undone pier
#

spring joint docs. Why is the second sentence in each of them the same

rich adder
rocky canyon
#
Frame 1: Update()
Frame 2: Update()
Frame 3: Update(), FixedUpdate()
Frame 4: Update()
Frame 5: Update()
Frame 6: Update(), FixedUpdate()
Frame 7: Update()
Frame 8: Update()
Frame 9: Update(), FixedUpdate()
Frame 10: Update()
Frame 11: Update()
Frame 21: Update(), FixedUpdate()
``` Update and Physics kinda happen like this

OnCollisionEnter, OnCollisionStay, and OnCollisionExit are all ran immediately after the physics step, which itself happens inside the FixedUpdate cycle.
sour fulcrum
rocky heart
#

ik ik im gonna fix it later

naive pawn
naive pawn
keen dew
rocky canyon
#

slightly.. lol theres lots more stuff inbetween and more often

#

but its the gist of it..

naive pawn
#

throw a 40ms lag spike in there and suddenly you have 2 FixedUpdates back-to-back

rocky canyon
#

lol.. very true.

naive pawn
#

it may as well be random which is "called first"

rocky heart
keen dew
#

Doesn't matter

rocky heart
#

oooh

#

ok

rocky canyon
alpine fog
rocky canyon
#

whats ocs ?

#

ohh oncollision something.. i imagine

naive pawn
rocky canyon
#

ahh gotcha.. ya in the grand scheme of things ive never really thought bout it

keen dew
#

Then put Debug.Log($"Trying to destroy {instantiatedCheeseSliceShadow.name}"); before the destroy and see what it logs right before the error

rocky canyon
#

u can see more context from OP.. even if still kinda vague-sh

naive pawn
#

yeah definitely an x/y problem

alpine fog
#

@rocky heart

according to the naming of your variables, you want to instantiate the placeholder 3 times? In that case you're doing it wrong
just assigning it to placeholderObject does not create a copy it's a direct reference. You need to assign Object.Instantiate(placeholderObject) and then it becomes a copy of the placeholder object

otherwise when you call Destroy(instantiatedSkateboardAttack) it is trying to destroy the original placeholderObject which if it is a prefab is not allowed

rocky canyon
#

good catch ^ ur reassgining it most likly

keen dew
#

I don't know what's the deal with the placeholder objects but there's a check before the destroy that makes sure it's not the placeholder

#

It might be related sure

rocky heart
#

wait why does it say Trying to destroy CheeseSlice1Shadow and not instantiatedCheeseSlice

rocky canyon
#

Debugging the actual objects (with decent naming) should sort it all out

rocky heart
#

huh

keen dew
#

It's printing the name of the object, not the name of the variable

rocky heart
#

oh ok

#

ok, now what

keen dew
#

Ok I see it

#
if (instantiatedCheeseSliceShadow = cheeseSlice1Shadow)
rich adder
#

nice

keen dew
#

Comparison is ==. This sets the value to the prefab

sour fulcrum
#

it is lowkey dumb that that can be valid code

keen dew
#

Yeah I don't understand why it's allowed

sour fulcrum
#

or at the very least not insanely warned by vs

rocky heart
#

oooooooooooooooooooooooooooooooh

#

thx omg

naive pawn
#

and it's allowed since the rhs is a UnityEngine.Object which has an implicit boolean conversion

brisk night
modern rampart
#

This might be a loaded newbie question, but how do I go from not knowing very much at all about coding, to making an RPG style game in unity?

sour fulcrum
#

A lot of time and patience

#

And probably games that aren’t rpgs

modern rampart
#

The programming class I took in high school was a joke

rich adder
#

RPG is def not what you want to start with

modern rampart
#

Probably a simple platformer first?

rich adder
#

sure , anything with simple logic / not a lot of moving parts

grand snow
#

want to learn programming? do that, then come back to learning unity and using your new skills

modern rampart
#

I don’t much care for programming outside of game dev

rich adder
#

You still need the basics

ivory bobcat
#

Could probably get away with the basics

rich adder
#

basic syntax, basic types, functions, collections, yada yada stuff like that

#

anything unity related is the API itself and a few core concepts you need to know like "what are gameobjects? components? " etc.

grand snow
ivory bobcat
#

Game development is more than just programming but will require some level of programming if you're wanting more features

grand snow
#

It is but if you cant actually code the logic it wont work

modern rampart
#

I see, and this is learnable online? Should I take a class?

ivory bobcat
#

Oh, the very basics are necessary. Who knows when you're going to have to debug a future game bug later

rich adder
#

You will learn basic stuff you need like store values in variables etc.

#

w3schools is okay too sometimes for quicker stuff

modern rampart
#

Oh awesome thanks yall

rich adder
carmine ocean
#

hey im having an issue where it says "The name "MouseX" does not exist in current context"

ive been on this for a little while and couldnt find out what it is wrong could someone help me out?


public class CameraController : MonoBehaviour
{
    public Transform transform;
    public float MouseSens = 2f;
    
    void Start()
    {
        
    }

    void Update()
    {
        MouseX = (Input.GetAxis("Mouse X"));

        transform.Rotate = MouseX * Time.deltaTime* MouseSens;
    }
}
grand snow
#

float MouseX =

carmine ocean
#

please do correct me on any bad practices i would be thankful

naive pawn
#

don't use deltaTime on mouse delta

grand snow
#

you need to declare the type to define a new variable

naive pawn
#

it's already per-frame

carmine ocean
grand snow
#

c# basics time!

cosmic quail
carmine ocean
carmine ocean
primal trench
#

how do i get the name of a textasset

sour fulcrum
naive pawn
cosmic quail
primal trench
grand snow
#

it exists on all UnityEngine.Object types and should just be the name

#

so no need to do anything to it

patent wedge
grand snow
#

why? using it with Quaternion.Euler() is fine

naive pawn
#

(they want a linear range for mapping onto a different range)

#

im not sure that's really an issue though. you could just offset it

grand snow
#

yea +180 would push it to 0-360

primal trench
#

another dumb question bc im bad at cs, im from godot, let

#

s say i have a function called like

#

pause game, and i want it to be accessed from any script, would that be one of those singleton things or a public void

naive pawn
#

those are separate concepts

#

singleton means the instance is easily retreivable
being public means the member is legally accessible

#

also, no such thing as a public void - that'd be a public method that returns void

naive pawn
#

it doesn't make sense

grand snow
#

Perhaps too pedantic for a beginner channel
You can use a "singleton" static field to access some component with a Pause() function or have the Pause() function be static itself.

naive pawn
#

wdym too pedantic lol
this is a common misconception

grand snow
#

well we can tell they mean a public function, weakly typed langs dont teach people these things well

naive pawn
#

it's also a common correction here... it's not a pedantic thing at all, it's a basic concept where the term happens to not be a keyword

ivory bobcat
#

Not sure why you're wanting global-like members for. Hopefully not because you're wanting to avoid proper referencing.

primal trench
grand snow
patent wedge
silver fern
#

if I destroy an object thats in a list, will the corresponding entry in the list also be removed?

grand snow
#

no

#

no magic like that exists, you would need to set up something to remove the object from the list when its destroyed

#

Or you just check for destroyed items when looping over the list and remove them as you encounter them

silver fern
#

rn I have private void Update() { for (int i = EffectsList.Count - 1; i >= 0; i--) { if (EffectsList[i].effectDuration <= Time.time) { StopEffect(EffectsList[i]); EffectsList.RemoveAt(i); } } } where StopEffect() destroys the object, so that should be fine right?

grand snow
#

Oh well you are removing it right after so no problems there
BUT I thought what EffectsList held was not a component? The unity concept of "Destroying" is only applicable there

ivory bobcat
#

Your iteration may become off though Nevermind, reverse loop

silver fern
#

It holds the effect objects, mainly to easily check their timers in Update

grand snow
#

that doesnt answer my query

#

anyway you remove this from the list so i see no problem

naive pawn
silver fern
#

it seems to be working though

grand snow
#

yea because you removed it from the list so its gonezo

#

perhaps you are confused about something?

silver fern
#

does it just stay in memory forever in this case? I didn't get an error message with destroy or anything

naive pawn
#

there's kinda 2 layers to it

grand snow
#

GC takes care of it 🧹

silver fern
#

in other words the Destroy is superfluous if I just remove it from the list?

grand snow
#

"oh look nothing references this object i will delete it now!" -GC

grand snow
ivory bobcat
naive pawn
#

there's a c++ layer that unity manages, and there's a c# layer that the runtime manages
c++ memory is handled manually, c# has automatic memory management

UnityEngine.Objects are basically wrappers to the actual objects in c++ land
when you Destroy an object, the c++ version gets destroyed, and the wrapper becomes invalidated, but not magically destroyed

silver fern
ivory bobcat
#

If it's a plain c# object, it'll be collected by the garage collector - eventually.

naive pawn
grand snow
naive pawn
#

much more flexible and you can actually manage them

grand snow
#

BUT you will need to "start" the coroutine from a monobehaviour

naive pawn
#

same for InvokeRepeating, so i don't see the issue

grand snow
#

are we sure about that?

#

Isnt that meant to work only on the instance its used on?

naive pawn
#

...same for StartCoroutine?

grand snow
#

no we can start a coroutine and pass the returned IEnumerator from anywhere

#

if we used the function name then that does not work

naive pawn
#

im not sure what you're talking about

#

"returned IEnumerator"?

#

StartCoroutine takes an IEnumerator

patent wedge
#

with the joystick to angle to 45 degree increments it has issue when round values near 360 i want it to round back to 0.

naive pawn
#

and not using the function name is a good thing, actually

grand snow
#

StartCoroutine(genericClass.Thingy())

ivory bobcat
naive pawn
#

StartCoroutine and InvokeRepeating are both non-static, public methods of MonoBehaviour

#

i honestly have no idea what you're trying to say

naive pawn
grand snow
silver fern
#

is it a big disadvantage to use InvokeRepeating?

grand snow
#

well its not that great and is probably acting as a crutch for you rn

silver fern
#

mainly it's for dealing x damage every y seconds

grand snow
#

you could call a function on your effects each Update() and implement the same functionality

naive pawn
grand snow
#

we did discuss this like 1 day ago 😐

naive pawn
#

this sounded like you were saying coroutine was worse

grand snow
#

Nah it was in relation to if effect object is changed to not inherit from MonoBehaviour

naive pawn
#

but that would apply for InvokeRepeating too in that case

grand snow
#

yea

naive pawn
grand snow
#

the point was you can still use coroutines without MonoBehaviour blah blah that overload blah blah

#

anyway im done 👋

silver fern
#

ok thanks

shy yew
#

bro can someone help me , i just started to learn how to make 2D game ( im new ) and i want to know how can i make light additive and that not everything goes black when i put a light , like if they adds up

patent wedge
#

how could i do a mathf.movetowards with duration rather than speed i already tried

var val2 = Mathf.Movetowards(val * Time.deltatime)```
naive pawn
shy yew
#

ok thx

naive pawn
#

also MoveTowards is not spelled like that and it takes 3 parameters
is your ide configured

patent wedge
naive pawn
patent wedge
naive pawn
#

yeah don't do that

#

that'll just introduce new problems or obscure existing ones

#

what's your actual code

patent wedge
ivory bobcat
#

That doesn't look like it'll compile.. UnityChanThink

patent wedge
naive pawn
#

doesn't really change it

#

the guy asking is typically not the person who knows everything

silver fern
#

isnt it val1 inside move towards

patent wedge
silver fern
#

what did you name them for yourself?

naive pawn
#

oh my god show your actual code instead of changing random stuff that breaks or fixes it

patent wedge
silver fern
#

it's best to name your variables so its always clear

naive pawn
#

there we go

patent wedge
naive pawn
#

you weren't even feeding a new value to movetowards before

naive pawn
naive pawn
#

is SlideDuration supposed to be in minutes or something

patent wedge
naive pawn
#

also that's recomputing the difference every time, so you end up with a smaller distance covered each time - you'd have to pre-compute the time

naive pawn
#

stackoverflow questions are not particularly good places to get code from

silver fern
#

what does duration instead of speed even mean

ivory bobcat
naive pawn
patent wedge
silver fern
#

ah ok

#

cant you just calculate the speed for that

ivory bobcat
naive pawn
silver fern
#

well speed = distance / time, so time = distance / speed

naive pawn
#

the issue here is they're recomputing speed with the new value of distance every frame

#

you have to somewhat keep a state anyways

#

lerp would probably be easier, but that might not support their usecase thonk

#

what should happen if a new note is selected before you're done transitioning to the previous one?

patent wedge
silver fern
#

then just calculate the distance once

ivory bobcat
#

It doesn't get slower if you're using proper lerp

silver fern
#

it gets slower if you keep recalculating with shrinking distance

#

then you get a curve

ivory bobcat
#

May as well go for slerp at that point

patent wedge
ivory bobcat
#

You aren't wanting a slerp pattern as far as I'm aware

naive pawn
#

you need to use actual lerp

ivory bobcat
#

You're wanting the proper lerp

naive pawn
rich adder
ivory bobcat
naive pawn
#

thinkies completely missed it lol

patent wedge
#

any ideas?

patent wedge
ivory bobcat
patent wedge
naive pawn
naive pawn
patent wedge
#

i'm using movetowards.

naive pawn
silver fern
#

well use lerp

ivory bobcat
naive pawn
# patent wedge cause i'm not using lerp.

you said

rather than something like a lerp where it gets slower and slower.
this is wrong lerp

lerp stands for linear interpolation. it's linear if you use it correctly

patent wedge
#

also remember the values are constantly changing.

ivory bobcat
#

I'm not willing to write the code so you'll need to Google a bit or use one of the other mathematical solutions

naive pawn
#

the solutions we've cited do

silver fern
#

don't use movetowards

naive pawn
#

movetowards is fine

#

it's lerp taking different values

patent wedge
low goblet
#

is there any other way to prevent

No measure function set in this node's config
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

spam in 6000.2 besides restarting the editor? when i restart the editor, it goes away for about 5 minutes and then comes back.

rocky canyon
#

speed = distance / desiredTime

naive pawn
naive pawn
#

it's arbitrary because your current usage of movetowards is effectively just wronglerp lmao

patent wedge
ivory bobcat
naive pawn
#

because you're using the updated value of frequency each time

low goblet
naive pawn
#

@patent wedge you should stop assuming things you don't know

lerp and movetowards are the same math, both are linear if used properly
the problem is you aren't using them properly
like you said - keep in mind, the values are changing!

the important thing is using the proper values in each iteration
for movetowards: don't recompute time, use new position
for lerp: use original position, remember elaspsed time

you can use either lerp or movetowards here - again, it's the same math.
just make sure to update the variables that need updating, and don't update the ones that don't.

you don't seem to have a separate current vs target variable, so yeah movetowards would probably be more straightforward
but if you want it to be linear, you have to not recompute the speed every frame, because that would take the new distance and you end up with an exponential decay - the exact thing you were complaining about with (wrong)lerp

#

oh and yeah get rid of random coefficients you can't explain lol

ivory bobcat
#

Proper lerp and move-towards with linear non-changing speed.
Lerp:cs c = Lerp(a, b, t)where t would go from 0 to 1. Where t = 0 would have the value be a and t = 1 would have the value be b. t should not be some constant fraction in proper lerp.
Move Towards:cs a = MoveTowards(a, b, speed)where a would increment by an amount equal to speed till it's the value b.

pine bone
#

hello, im planning to create a robot construction game where you build your own robot in a 2d grid and run the simulation to see how your robot behaves on its own, im planning to add a small code editor to add your own logic to your robot, does anyone have any suggestions on how i would structure the robot?

naive pawn
ivory bobcat
patent wedge
naive pawn
#

yes, that's what speed is

#

the issue before was that - again - you were recomputing it with the updated distance. you need to keep the same speed, calculated from the starting distance.

ivory bobcat
#

Meaning diff should only be evaluated once

glad hazel
#

Is it ok to put logic inside a class that is also a scriptable object?

stuck current
#

I’ve asked this earlier but is there any projects I can look into to observe the framework and see if I’m doing anything wrong and improve

timber tide
knotty tiger
#

hey everyone, im trying to export my project to my friend who has mac, for some reason it wont open for him and displays a tab saying the application cannot open. anyone know a fix?

knotty tiger
#

trying to send it to my friend over dropbox using files

rich adder
knotty tiger
#

the build yeah sorry

rich adder
#

are you exporting from a mac

knotty tiger
#

no im exporting from windows

rich adder
#

does windows support export single app file ?

#

anyway your friend can try seeing if its probably being blocked in the privacy setting.. since its from an unverified/unknown developer according to apple ..

knotty tiger
#

when exporting i get the .app file and then contents and finally the rest of the stuff in it

rich adder
rich adder
knotty tiger
#

these are my settings and the inside of the contents folder which is in the .app folder

rich adder
grand snow
#

guess apple couldnt be bothered to make it an blob

rich adder
#

hmmm on here they are in a couple of folders deep

knotty tiger
#

it is maybe that i compressed the folders and its something to do with permissions?

knotty tiger
#

is there any way to not compress the file and send it

rich adder
#

put it inside another folder and zip that

primal trench
#

another beginner question, if i have a player health that i want to be stored throughout scenes, where would i put that?

potent hornet
#

Does anyone know why my linearVelocity is Vector3.zero, I don't think I'm calling to it anywhere else

rich adder
potent hornet
#

It's not, but I think I might have found the issue

rich adder
#

danggg.. cache your vars / components
so many repetitions can be avoided

potent hornet
#

Nevermind I didn't

rich adder
potent hornet
#

No, the animator's float is changing as expected, but the linearVelocity is still Vector3.zero

rich adder
#

is the animator taking over the transform maybe ?

potent hornet
#

What would that mean, and how could I tell

rich adder
#

disable it / remove it, and comment out the animator lines

grand snow
#

hmm good idea

primal trench
rich adder
primal trench
# rich adder wdym ?

idk there's so much controversy about singletons, i thought i heard somewhere you should only have one singleton

rich adder
#

just dont abuse / use them as crutch

primal trench
#

would i also wanna use this for 'global' functions like, idk pause game?

rich adder
#

yeah they generally used for that like GamePlayManager or something that controls flow of the game

#
  • DDOL so they don't die between scenes
potent hornet
#

I closed my project and restarted it and it worked. But it was giving some animator error about an object not being set and Null Edges or something

#

I'll have to screenshot that next time, but also thanks!

warped sierra
#

Unity 2022 is riddled with bugs. The build window is incredibly slow, the MP4 player is incredibly slow, and this bug. 🙁

copper python
#

Could anyone help me with my (not at all beginner level) problem in Unity? It's about i's value in a for loop magically changing by black magic whilest trying to run a async method. The problem is rather complex so that's why I'm asking to ask XD

#

Example snappet:

            for (int i = 0; i < operations.Count; i++)
            {
                var op = operations[i];
                var localProgress = new Progress<float>(p =>
                {
                    float groupProgress = (i + p) / operations.Count;
                    Debug.Log($"i: {i} | p: {p} | groupProgress: {groupProgress}");


                    progress.Report(groupProgress);
                });

                await op.ExecuteAsync(localProgress, token);
            }
rich adder
#

by the time that lambda run the i can be different

#

so capturing it like that should ensure its the value you expect it to be

var op = operations[i];
int index = i;
var localProgress = new Progress<float>(p =>
{
    float groupProgress = (index + p) / operations.Count;
    Debug.Log($"i: {index} | p: {p} | groupProgress: {groupProgress}");
    progress.Report(groupProgress);
});```
rich adder
#

don't even think 2.0 was actual LTS / full release (I think it was tech stream?)

#

so riddled with bugs makes sense..its literally a preview release ?

#

what are you trying to do anyway?

copper python
copper python
#

I went crazy for over 7 hours trying to fi this

warped sierra
vital vault
#

How can i make my class editable from inspector?

polar dust
smoky ruin
#

Guys, just one question, which is better for a fast paced FPS, charactercontroller or rigidbody?

rich adder
#

kinematic

remote vault
#

hey im debugging a little input system for the player and it shows this error on console, whats the issue and how do i fix it?

sour fulcrum
#

What does the error say

remote vault
#

ill show you

rich adder
remote vault
remote vault
stray crag
#

whenever i create a new project it always starts witht his error message: CommandBuffer: built-in render texture type 3 not found while executing (SetRenderTarget depth buffer)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

stray crag
#

sorry

#

i thought i had the wrong chat

remote vault
#

btw thanks nav i got it to work

#

i set it to use both input systems how come it says its recommended to not use both input systems?

rich adder
#

its pretty easy to use the new system, keep it on both then phase it out as you learn new one

remote vault
#

ok thanks

umbral bough
#

Hey, I am using this singleton asset:
https://github.com/UnityCommunity/UnitySingleton
It's supposed to support editor scripts too, according to this:
https://github.com/UnityCommunity/UnitySingleton/issues/2
However, I keep getting spammed with the error seen in the picture.
I simply call the manager like this:

private static Transform Player => ColosseumSceneManager.Player.transform;

private void Update()
{
    // Move camera to the player's position to allow for proper offset after rotation
    transform.position = Player.position;
    if (_rotateCamera) Rotate();
    Offset();
}

Am I doing something wrong or is this a bug?
Please @ me and thanks in advance!

#

btw, I am using the latest Unity 6.3 alpha, that could be the cause.

timber tide
#

line 29

umbral bough
#

Could this be a bug?
I'll try deleting the library dir as I was doing some weird stuff just before this happened so maybe that corrupted or sm.

timber tide
#

Why's the numbering here labled like that

umbral bough
#

relative line numbers

#

vim mode

timber tide
#

What does that mean? Is the line above 29 here right before

umbral bough
#

yes, the line above 29 that says 1 is line 28

#

it shows the number of the line you are on and the others are relative to that

#

Here, I toggled it to make it easier for you.

timber tide
#

Try commenting out 6, I'm just curious if it's complaining about that

#

or rather w/e 6 is here

umbral bough
#

like the 6th line in the colosseum scene manager?

timber tide
#

What I'm eyeing from the error is 'instance field initializer' from the debug, but I'm not seeing a FindAnyObjectByType call

#

FindWithTag however is a similar Find operation

umbral bough
#

ah, that's from the singleton implementation I am using

#

btw, wasn't the library dir, I just rebuilt it and all the same sadly

#

I think this has something to do with how I am accessing stuff in the ctor but I honestly have no clue...

#

Like is this not a proper way to access a variable from a singleton?

[SerializeField, Required] private CameraManager _cameraManager;
public static CameraManager CameraManager => Instance._cameraManager ??=
    Instance.gameObject.GetComponent<CameraManager>();
umbral bough
#

Oh wow...
It took ai pointing this out for me to notice o_0
See something weird about this line?

public static float DestructionVelocity = Instance._destructionVelocity;

Yeah, I used = instead of =>, which caused initialization and an error.
I genuinely don't know how I managed to miss this one, literally never happened before.
Thanks for trying to help!

rich cradle
#

hi i am new in unity and i am wondering if i have learnd java can i use it for unity?

sour fulcrum
#

no

#

but c# is very similar

#

very very

rich cradle
#

ok thx

potent turtle
#

Technically you can if you're specifically writing native code for Android. But not in a way that matters for general game development

rich cradle
#

do yall have som tips for what game i shud make?

potent turtle
#

Whatever you want. Start small though. Learn the engine before trying to make anything too big. Starting on a large project right off the bat is a recipe for frustration

trim eagle
#

aww

#

shucks

rich cradle
rich cradle
#

and low poly

potent turtle
#

3D?

rich cradle
rich cradle
potent turtle
#

Just wondering. Just looking at the trailer for Karlson making that game exactly will be tricky and take a lot of time. Just start small, work your way up from there. Start with just a player controller that you can move around and jump with, and add all the other stuff on top of that

rich cradle
potent turtle
#

Make sure you have Visual Studio (or Visual Studio Code) set as your external editor

#

Assuming you mean that when you double click a script in the asset browser it opens Notepad

potent turtle
#

Yeah they do the same thing

rich cradle
#

so i need yo go downlode Visual Studio

potent turtle
#

Yeah. The Community edition's the one you want, that's the free version

junior ivy
#

Hi, I'm experienced programmer but I'm new to the game dev and I'm shocked how different this is from actual programming.
I would like to talk about dependency injection / OOP.

I found that there is no such thing as a front controller in unity (same in godot and other engines except low level graphic APIs where I programmed everything myself).
Also there is no such thing as dependency injection.
No such thing as service container as well...

This makes OOP pretty much impossible in unity but I found 1 solution: lazy injection, which is passing dependencies after the class instance is created.

Problem: I want to use a component in all game objects but it looks unnecessary and memory consuming to call AddComponent every time I initialize game object. I don't need "unity-level" dependencies in my code... I need my dependencies in my code. Since there is no service container, I cannot get component from something global... instead unity prompts me to add component to the game object if I wanna use it. That's unacceptable.

#

Solution:

// THIS IS MY FRONT CONTROLLER, THE GAME STARTS ONLY FROM HERE
// ALL INITIALIZATIONS ARE PROGRAMMABLE (materials, game objects, components, call sequences), NO GUI IS NEEDED
public class Game : MonoBehaviour 
{
    void Awake()
    {
        var camera = new GameObject("Camera");

        var unityCamera = camera.AddComponent<Camera>();
        unityCamera.orthographic = true;
        unityCamera.orthographicSize = Config.resolution.y / 2;
        unityCamera.transform.position = new Vector3(0, 0, -1000);
        camera.AddComponent<DragCamera>();

        var mapEditor = new GameObject("MapEditor").AddComponent<MapEditor>();

        // Init is my method for lazy injection of camera because I don't want to do mapEditor.AddComponent<Camera>();
        // I don't even know if unity will create a new Camera instance or use the one from its internal instance contaienr initialized before Awake...
        mapEditor.Init(unityCamera);
    }
}

What do you think?

rich cradle
#

is the unity codeing c#?

sour fulcrum
junior ivy
#

How would you create singlefon of built-in Camera component and inject it in your classes?

#

I avoid singletons because they are anti pattern but I might do an exception for the game dev but only if there is not other choice. I found a solution already so I don't singletons but I want to hear opinion of game devs.

sour fulcrum
#

game dev'ing will break your spirits

#

it's arbitrary af 😛

junior ivy
#

hah, it already broke everything it could
I'm after few months of low level API/shader programming

potent turtle
junior ivy
eternal needle
# junior ivy I mean that I don't need to overhead my code with components if I can just pass ...

If you fight the system, you mostly end up with a struggle in trying to still use unity properly. You also lose out a lot on the actual benefits like configuring stuff in editor rather than through code. You'll find a ton more people here that dont bother with proper DI and instead just stick with a singleton where needed.
It also does sound questionable why your camera would ever be a singleton

eternal needle
junior ivy
#

yeah camera as a singleton was just a stupid example
I need proper OOP because it makes my life a lot easier and makes me do things because I like it (and I hate game engines in general)

#

yes exactly, "everything defined in code" is the way I want to go and I believe I can achieve everything with it just as you with GUI

#

I believe it's a matter of preference because I'm completely alone (no team) and it won't change. I will never call myself a game dev so I don't need to follow guidelines

eternal needle
#

Then use proper OOP however you like and treat unity simply as a way to render objects. Nothings stopping you from doing this and coding it exactly as you would outside unity
Ive only seen 2 people in this server defend this kind of style and I know one quit like 2 months in.

#

Again you can fight the system, but don't blame the system when you struggle to do basic things down the line

keen dew
#

You might be more comfortable with Monogame for example which is still C# but unopinionated. You're not going to have a good time with Unity if your preferences clash with how it's designed to be used

junior ivy
#

I want to give it a try at least 🙂 let's call it a challenge

#

I decided to use unity because godot is very poor if it comes to 3D, shadows and performance (I tested it, it's my opinion). Unreal is too much for me...

eternal needle
#

All the power to you if you wanna write it that way. Your game will function the exact same as someone who doesnt write it that way. Will it get produced faster/have more players? No

sour fulcrum
#

Like in a literal sense yes

#

in a practical sense nah

#

especially for 3d

eternal needle
#

Theres a lot that instantly break the workflow too, like the fact unity already has a lot of components with values you arent going to be setting in code

junior ivy
#

"everything" is a big word, it's obvious I won't do literally everything is code

eternal needle
#

Even the amount that youre thinking of doing is still the same issues

#

No one's physically restraining you from doing it, but trust me you're going to be questioned by almost everyone who helps in this server for doing it in a non unity way

junior ivy
sour fulcrum
#

ai is shit for unity and most things

#

your going to struggle a lot here

#

if your fine doing so by all means

#

by design this is just a bad way of using the engine

junior ivy
#

well AI is horrible but much faster than learning the doc, it speeds up self-learning a lot

eternal needle
#

This sounds like an abysmal way to code

eternal needle
#

But 🤷‍♂️ call it preference if you want. I dont think I can give anymore big red flags than I have already

junior ivy
#

the only real problem I see is that my project won't be maintainable by anyone except me (and it's good, I'm really doing it just for fun)

eternal needle
#

"Except me" wont be the same you in 6 months. The same reason people comment their code if they're the only one using it

junior ivy
#

anyway thanks, I just wanted to know if there are any real blockers

sour fulcrum
#

practicality

lament leaf
#

How do you fix the problem in a 2d platformer, that when you are falling and just holding D into a wall and you just dont fall as long as you hold D (or the Key for moving in a direct)

reef bramble
#

any1 know how I can change this value via code in hdrp: the temperature.

spice sand
#

Hi guys is it possible to get the volume level of audiosource while playing using update()? Completely slience = 0.00f, loudest = 1.00f

grand snow
knotty tiger
vital vault
vague pier
#

I am very confused. I have a few Item prefabs for my game and i have the unity version control enabled. For some reason, everytime i change something on 3 specific items, almost every time i launch the game in unity the prefabs reset back to what they were before. Even completely creating them anew doesnt help but its only with those specific 3 and i dont understand why

#

They also dont get automatically checked out if i change anything

#

but even manually checking them out doesnt change it

#

Could anyone help/explain why this is happening?

#

update i disconnected it from version control to see if its that but nope

violet juniper
#

Hi, I'm trying to write some tests for my code, but the editor doesn't seem to be able to create any test scripts anywhere, I always get the invalid path error.

I feel like I'm following the documentation, I create the test assembly director, but then when I go into the test runner and click create test script I always get an error

keen dew
#

Show the error message

gentle trellis
#

I'm trying to do a perspective change from front facing to back facing when the player enter this collider, how do I make it so it transition smoothly instead of instantaneous

fallow knot
#

hello guys, Why can't I find the playerprefs database in my browser (Chrome)? I know they work because I output their data to the console, but I can't find them in IndexedDB?

rocky canyon
#

ie. you could have 1 cam w/ a certain followTarget
you could have a 2nd cam w/ a different followTarget and just swap between the 2 cams instead of chnging out the followTarget

gentle trellis
#

im trying to invert the movement by multiplying by -1 if it's enter the collider, it worked but how do I time it so it doesn't invert instantaneously

grand snow
#

Well currently does the inverting of input cause the player to leave very soon after entering this area?

gentle trellis
#

yea it does, I currently only inverts once enter

#

should adding a timer work?

grand snow
#

Perhaps yea when they exit the trigger it can be a delayed change (which you would want to cancel if they re enter the trigger again)

#

you could use a coroutine or async method to do this

gentle trellis
grand snow
#
private void IEnumerator SetInvertAfterDelay(Player player, float invert)
{
  yield return new WaitForSeconds(0.5f);
  if(player != null)
  {
    player.invert = invert;
  }
}
#

start with: StartCoroutine(SetInvertAfterDelay(player, 1f))

grand snow
gentle trellis
#

do you use blend tree?

red igloo
gentle trellis
#

sorry

grand snow
#

Does the "forward" dir of this object match the visuals of the object?

#

forward being Z+

red igloo
grand snow
#

So the issue was that it instantly changed? You didnt add anything to do that so what did you expect???

#

You can use Rotate towards to rotate over time to some target rotation easily (as you can call this every frame with your current "target rotation")

red igloo
grand snow
#

I think you got lost during your search

#

Rigidbody.MoveRotation() is to change rotation using the rigidbody interpolation to help but this on its own wont fix the issue if your models "forward" does not match the visuals.

tiny crag
#

this isnt really about code but:
why is there not a color option in the camera inspector?

grand snow
#

but setting transform.forward as you were can work as long as the direction is world space

grand snow
tiny crag
grand snow
#

well thats different

#

the scene BG and camera clear are related but not the same thing

#

anyway ask elsewhere in future

tiny crag
grand snow
tiny crag
#

ok thx

red igloo
grand snow
#

Looks fine to me but I didn't really help did I 🫠

rocky canyon
red igloo
#

how would I make the turning more smooth? should I use vector3.lerp?

#

or quanternion slerp/

rocky canyon
#

sure, or MoveTowards, SmoothDamp, etc

#

lots of ways to do it..

grand snow
#

What about what I mentioned above

red igloo
grand snow
grand snow
#

Yes. You can do degrees/Time.fixedDeltaTime to make it be degrees per second.

#

But should be working already

hallow acorn
#

hey, what would be the easiest way to make a countdown for a stamina bar, or a hunger bar for example?

wintry quarry
#

it depends what part you mean exactly

#

the UI bit?

#

The actual timer logic?

hallow acorn
# wintry quarry the UI bit?

no ui isnt important rn its more of a hidden countdown for hunger etc which gradually gets smaller, depending what you do. so ill just subtract a multiplicator * time.deltaTime from my hunger efloat?

wintry quarry
#

you said "depending what you do"

#

so sounds like you'd subtract from it in response to some actions by the player

hallow acorn
#

for example faster movement would use up more hunger

wintry quarry
#

it also depends on if these things are "continuous" actions ( like running) or one-off actions (like swinging an axe)

#

but it's really not complicated

#

stamina -= staminaCost; for one-offs
stamina -= staminaCostPerSecond * Time.deltaTime; for continuous actions

hallow acorn
#

its for little npc characters having random stats so some move faster then others etc. there arent really one-offs and i dont plan on implementing those

gentle trellis
gentle trellis
potent eagle
#

I'm not sure why but my player keeps floating upwards every time I press play and begin to rotate or go forward. Is there something wrong with my code?

rocky canyon
#

or for a stamina/health setup theres a combo of the two

 private void HandleHungerTick()
        {
            tickTimer += Time.deltaTime;

            if (tickTimer >= tickInterval)
            {
                hunger -= hungerCostPerTick;
                tickTimer = 0f;
            }
        }```
like for example every 2 seconds it takes 5 from hunger
this means u have to go the full 2 seconds for a deduction to happen
wintry quarry
rocky canyon
#

find it a cool mechanic from time to time.. (i like my status bars to have chunks to em)

potent eagle
red igloo
#

How can I make my player move freely while in the air? I basically change the movement speed when in the air is that a no go?

wintry quarry
red igloo
wintry quarry
#

looks like you're doing a force-based or momentum based system

#

if you want faster acceleration you need more force

#

based on the simple F = ma equation

rich cradle
#

what do yall think is 2d or 3d who is the most easy for a now dev

wintry quarry
#

Alternatively you could switch away from a strictly physical force-based system and set the velocity more directly

wintry quarry
rich cradle
wintry quarry
#

There are specific 3D game types that might be more complex - usually if you have complex 3D rotation involved like a spacship-flying game

#

but for most types of games, FPS or TPS for example, there aren't complex 3D rotations involved.

gentle trellis
naive pawn
#

and there are complex 2d things too!
2d vs 3d aren't harder or easier than each other - just different

rich cradle
red igloo
wintry quarry
#

If you want to do something very specific like "if I'm in the air and the player pushes their joystick in the opposite direction they're moving, I want them to be able to very quickly change directions" then you will have to write the code for that

#

e.g. psuedocode:

if (!grounded && horizontalInputDirection != currentHorizontalMovementDirection) {
  // do something special, either adding more force or instantly setting the velocity the other way, whatever you want
}```
violet juniper
hallow acorn
#
void Update()
{
    CalculateHunger();
}

private void CalculateHunger()
{
    currentHunger -= speed * 0.1f * Time.deltaTime;
    if(currentHunger < hungerThreshold)
    {
        LookForFood();
    }
    if(currentHunger <= 0)
    {
        Die();
    }
    print(currentHunger);
}```
this code should count down to zero but it always stays at its default value whic is set before. can someone tell me why this happens?
rich adder
hallow acorn
#

havent actually asigned a value to speed this might be an issue 😅

rich adder
#

seems like it , anything * 0 is 0 🙂

tough shard
#

Hey everyone, could someone explain to how Resident Evil's signature movement works but in Dev terms?

rich adder
tough shard
#

I'm trying to recreate that slow, realistic movement but I don't know how I should go about it :/

rich adder
#

resident evil changed movement through the years

#

are you talking about tank controls ?

tough shard
rich adder
#

thats not "signature" movement , those are more contemporary movements

#

so like FPS movement you probably want to look into whatever first person tutorials cover this topic

#

what makes those really stand out is the good animations, like any other FPV game

tough shard
#

I mean making an FPS movement controller is just as simple as that, but getting that realistic feel is a different thing (Mainly talking about Camera and Perspective)

tough shard
rich adder
tough shard
rich adder
#

things like swaying / bobbing are the terms you want to look into

tough shard
rich adder
#

pretty much

tough shard
rich adder
#

some games move the actual props you're holding, some sway the camera (some do both)

sour fulcrum
#

No one should want to perfect anything to start with though, systems like this are pretty iterative and a implementation in a game like RE is going to have a ton of time, experience and testing involved to make it that good, so don’t be too surprised if you end up short of that

rich adder
#

at the end of the day they have dozens of animators that know what they're doing to sell the realism . Strictly talking about the movement mechanics, they are pretty generic

tough shard
sour fulcrum
#

Could be wrong but probably not tbh, that doesn’t sound like enough consistent control

tough shard
#

Things like rough surfaces would move the camera differently and so on. Purely because of how the physics are working on it

rich adder
tough shard
sour fulcrum
#

The camera doesn’t have to be realistic, it has to feel realistic

tough shard
#

But yeah, so if I understand this correctly, I should focus on Swaying and Bobbing to get that slight realistic effect?

#

I mean to start it'll be simple, slowly changing to the style of the game

sour fulcrum
#

Sounds like a good route to down yeah. If your really serious about this might be worth looking for any available gdc-esque talks on this kind of thing or even finding similar games that have view bobbing or other relevant settings available so you can compare the difference

elfin acorn
#

Hi

tough shard
rich adder
sour fulcrum
#

I would hope so but it can get dumb when your looking for actual industry discussion and resources, you can probably find good stuff

tough shard
#

I'm actually trying to make a survival horror game (Of course not as good as Resident Evil but I'll try). So yeah, I LOVE the new Resident Evil movement style, I'm stealing taking inspiration from it

rich adder
#

not a bad idea, the new Resident Evil def breathe new life into the game . Def brought the franchise back

tough shard
#

It got really close to what I was looking for at the moment but I'll be making my system instead

rich adder
#

yup exactly, like everything else it needs to be "tuned to taste" so keep iterating eventually you will get the look you want

tough shard
#

If this fails I can always go to a complete Resident Evil 5 style 😴

violet juniper
#

Help, I've been trying to create play mode tests for a week and i can't seem to understand why i can't do it

violet juniper
#

for the code

rich adder
#

you mean like Unit test?

violet juniper
#

yeah

#

play mode tests are unit test which simulate the engine basically

rich adder
#

I know what unit tests are just didn't know the name " playmode tests" was a thing. maybe if you show the setup and explain a bit someone whats not working , someone might be able to chime in

violet juniper
#

Thanks, well

#

All i'm doing is I'm following the documentation on how to create tests and test assemblies

rich adder
#

alright, you need to give more info if someone is to attempt at all to help debug this

#

we are not mind readers

violet juniper
#

I have my scripts i want to test in a folder, then i created a test assembly folder through the asset section, then I told the created assembly file to reference the one in the script's folder, and finally i try to create a test script by selecting the test assembly file and using the test runner feature "create new test script" but I only get the "invalid generated unique path" error

rich adder
neon forum
#

Generally, for a turn based card game, should I use coroutines for things like turns and playing a card?

#

I'm not really getting into the specifics yet, only a general framework I should follow before I implement anything

violet juniper
#

I feel like main game logic can stay in the update function

rich adder
violet juniper
#

coroutines seem like they would be useful for time sensitive things such as animations and effects

violet juniper
rich adder
neon forum
#

I'm also coding this to be multiplayer(internet stuff), could I build a turn-based framework and then build the multiplayer on top of that or would that cause a mess?

rich adder
# violet juniper 6.1

are you able to try unity 6.0 . just curious if this is some type of bug , i seen this error before

rich adder
neon forum
#

got it, well if that's the case I've already finished the non-networking parts(deck building), I guess I should add in the networking part now?

rich adder
#

and try making the same code/ project
if its still bust its probably you did something wrong at some point

neon forum
#

How do I code with networking in mind? Is it like telling the game manager that there'll be a player 1 and player 2 but player 2 is a try/catch check for internet connection/lobby system?

past yarrow
#

why does it ask me to make that field static ? 🤔

slender nymph
#

you cannot access a non-static member in a static method (without an object reference)

rich adder
#

thats the whole point why Networkmanager has a singleton

#

its even in the documentation

#

wait wrong link

#

holy shit the new docs , are the old docs ...

rich adder
#

I have no fucking idea why they changed that...or the docs..

neon forum
#

I feel like unity has a habit of doing that

rich adder
#

it literally was just NetworkManager.Singleton.StartServer() etc.

past yarrow
rich adder
past yarrow
sour fulcrum
rich adder
#

they changed the docs in such a haste they fucked everything up

past yarrow
#

where can we report that please ?

rich adder
#

at the bottom

#

all the legacy links I had for Netcode docs now link to the package docs 🙄

neon forum
rich adder
#

the old docs for netcode was better imo but alas we're back to the shit Docs unity has now for packages

sour fulcrum
neon forum
#

so the link nav just posted?

rich adder
#

knowing when to use NetworkVariable vs RPCs

#

shit like that is more important

sour fulcrum
#

Still can’t get over NetworkVariable OnValueChanged not firing when it syncs a pre-existing value

rich adder
#

like initializing it ?

sour fulcrum
#

If a client joins a pre-existing session when they get the networkvariable values that doesn’t invoke the event on them

#

only if the value changes while they are in the session

rich adder
#

iirc on in networkspawn you usually want to do something like
MyValueChangedMethod(old , myNetval.value)

#

that tells connected client to sync the value

sour fulcrum
#

That’s a way to get around it but feels super jank and inconsistent

#

Makes getting comfortable with ngo a pain imo

rich adder
#

yeah that to me was a bit confusing for me as well

#

until i had to work with RPC params :X

#

the old method was easier than new one UnityChanDown

sour fulcrum
#

Apparently IsOwner not being set yet in behaviours when OnNetworkSpawn spawn is run too feels hmm

rich adder
#

still , NetworkVariable still feel like cheating..

#

its almost too easy lol such things would be so difficult just dealing with just RPCs

sour fulcrum
#

99% of my time in ngo is on something with pretty much no networkvariable use

#

Pain

silver fern
#

I'm missing something obvious but not sure what. I have a BurnEffect object that inherits from a EffectObject object. The BurnEffect has a IEnumerator Coroutine. Can I make that coroutine accessible through EffectObject?

rich adder
#

as long as they are started on a MB

silver fern
#

when I try to check effect.EffectCoroutine, where effect is an EffectObject, it says EffectObject does not contain a definition for the coroutine

rich adder
silver fern
#

so I wanted to check if that Object has a coroutine and start it if yes

rich adder
#

like a boolean or a more clever way