#💻┃code-beginner

1 messages · Page 587 of 1

north kiln
#

I don't understand how any ambiguity could exist now. What's the first compiler error (the top one) that shows in Unity?

old bolt
#

Assets\Scripts\PlayerControls.cs(1179,19): error CS0102: The type 'PlayerControls' already contains a definition for 'PlayerActions'

north kiln
#

So you also have a script called PlayerControls?

#

You're really gonna have to start coming up with new names lol

old bolt
#

No wait

#

I have a script playerController,PlayerControls(made by input system) and PlayerLocomotionInput

north kiln
#

Is Assets\Scripts\PlayerControls.cs the one that's generated by the input system?

old bolt
#

Yes

#

Wait

#

it made another Playercontrols.cs in the asset folder

north kiln
#

Delete the one that's out of date

old bolt
#

Assets\Scripts\PlayerLocomotionInput.cs(15,9): error CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.PlayerActions.Enable()'

Assets\Scripts\PlayerLocomotionInput.cs(16,18): error CS0572: 'PlayerActions': cannot reference a type through an expression; try 'PlayerControls.PlayerActions' instead

Assets\Scripts\PlayerLocomotionInput.cs(16,9): error CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.PlayerActions.SetCallbacks(PlayerControls.IPlayerActions)'

Assets\Scripts\PlayerLocomotionInput.cs(21,18): error CS0572: 'PlayerActions': cannot reference a type through an expression; try 'PlayerControls.PlayerActions' instead

Assets\Scripts\PlayerLocomotionInput.cs(21,9): error CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.PlayerActions.Disable()'

Assets\Scripts\PlayerLocomotionInput.cs(22,18): error CS0572: 'PlayerActions': cannot reference a type through an expression; try 'PlayerControls.PlayerActions' instead

Assets\Scripts\PlayerLocomotionInput.cs(22,9): error CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.PlayerActions.RemoveCallbacks(PlayerControls.IPlayerActions)'

We back at only 8 xD

rich adder
north kiln
#

Do you have an action map named PlayerActions?

old bolt
#

Player

#

your a genuis xD

north kiln
#

glad it's sorted 👍

old bolt
#

Thank you!

grand dome
#

Anyone know how to make the scroll wheel keybind more responsive, it takes a full revolution of my scroll wheel for it to register the keybind has happened

west radish
#

I haven't made use of scrolling with the new input system yet, but it should be the exact same equivalent in that

swift crag
buoyant finch
#

https://paste.ofcode.org/JKEKFxSCCLpwL6xd5NYXgP hello so in my code I have added collisions and want so that upon every key press the walk animation iterates through its frames even when colliding so currently it works for the first 2 frames but then it doesn't switch to the 3rd and 4th frames upon colliding

teal viper
buoyant finch
# teal viper Debug your code. Add logs or step through it with a debugger.

I debugged and found that this works only one time

    if (keyPressTimer >= animationFrameRate)
    {
        Debug.Log("Player can't move, animation updating.");
        keyPressTimer = 0f; // Reset the timer
        currentFrame = (currentFrame + 1) % currentFrames.Length; // Iterate the frame
        spriteRenderer.sprite = currentFrames[currentFrame]; // Set the new sprite
    }

    keyPressMode = false;
    keyPressTimer = 0f;
}
upper tide
#

Is there a way in general that i can avoid creating new functions for events to subscribe to

#

If possible I'd really like it if I could subscribe them all to a single ProcessButton

dire meteor
#

Hey anyone having issues where you assign buttons or objects in inspector but it still shows errors that they are not assigned? Idk wtf is going on

upper tide
#

and then sort the functionality out by if statements rather than being drowned in function statements

slender nymph
#

individual methods, while more verbose in the code, are going to be better performance-wise because you won't need to go through a long chain of if/else to determine what code to run. and if they each do something entirely different then there is even less reason for it all to be inside of one master method

upper tide
#

aye aye

#

I was hesitant to choose one or the other, but glad to hear that doing this sort of thing also works!

#

Thank you

teal viper
feral moon
#

Hey! So, I’m trying to figure out how to set things up in Unity. I want to make it so that when I click a button on an keyboard, a component gets turned on. And then, if that component is already there, I want it to turn off instead. How can I make that happen? Any tips?

If I uncheck the box, it remains visible. This happens in the actual game.

keen owl
cosmic dagger
teal viper
cosmic dagger
feral moon
teal viper
#

And where?

#

Visible in the inspector?

feral moon
#

One second please...

cosmic dagger
feral moon
teal viper
cosmic dagger
feral moon
keen owl
#

If you want that disabled, you don’t disable the component but rather the instance of that object via the code

teal viper
# feral moon I'm talking about the blue marker.

In unity, you have components that are responsible for visuals of the object, like SpriteRenderer, MeshRenderer, ui Image, etc... So if you want them to stop rendering, you need to disable them, not your scripts.

#

Unless your script has extra logic responsible for rendering(or controlling the components related to rendering)

#

Basically, go and !learn the basics:

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

cosmic dagger
cosmic dagger
# feral moon I'm talking about the blue marker.

If you want to prevent an object from rendering, you need to disable its renderer. If it's a UI object, you can disable the Image component or use a CanvasGroup component and manipulate the alpha property . . .

feral moon
keen owl
#

Disabling the object entirely also works but any code running on it won’t run so either do that or disable the renderers on it

sleek flare
#

Is it possible to add a instanced script to a gameobject? (Create a script, do some edits to it, then attach it to an object)

slender nymph
#

no, but why not just add the component then do the modifications to it immediately after calling AddComponent?

#

or you could just instantiate an entire gameobject (with the desired component on it) and set it as a child of that object

sleek flare
#

Cause I was wanting to pass a argument to the constructor of the script, which you can't do with addcomponent.

slender nymph
#

you can't do that anyway because invoking a MonoBehaviour's constructor does not create the MonoBehaviour on the native engine side so it won't correctly act like a component

cosmic dagger
north kiln
#

They do have constructors, you just shouldn't use it yourself, and there's rarely a reason to declare one

sleek flare
#

Ah

cosmic dagger
#

true, i was tryna scare them away from it. they're called multiple times in the editor and during runtime. it's crazy . . .

keen owl
#

isn't the Awake method similar to a constructor in unity's lifecycle?

slender nymph
#

sort of, yes. it can kind of be treated like a parameterless constructor. although you actually can define a parameterless ctor that will actually be called (though you would typically use Awake unless you had a legitimate reason to need to use the ctor)

keen owl
#

makes sense, I never actually written a constructor and thought about it which got me wondering about it, thanks for explaining that

buoyant finch
#

hello so my tilemap for solid objects has a composite collider with polygons but in some places polygons are not generated and my player doesn't collide with them pls help

cyan pasture
#

Hi! What do Unity attributes like [SerializeField] mean? Can someone list the most common ones and explain them? Thx 😁

grand snow
#

makes private fields be "serialized" and editable in the inspector

buoyant finch
cyan pasture
#

Okay, thank you. Are there any other popular ones?

verbal dome
#

Worth mentioning that serialiation doesn't just mean it's editable, it also means the value is saved and will persist. Non serialized values will use the default values when loaded

grand snow
#

you can edit it and that is saved in the scene or prefab or asset

molten dock
#

id like my my mouse to stop when it hits colliders, so i need to make an "in game mouse", how do i do that?

feral moon
#

https://hastebin.com/share/bixowekuda.csharp
https://hastebin.com/share/atacikebus.csharp
https://hastebin.com/share/urujepudaq.csharp

I need help... How to make the distance text false when focused=true for the object?

verbal dome
molten dock
verbal dome
#

The second approach would allow instant movement. First approach uses velocity so it might not be instant.
Depends what you want of course.

molten dock
#

okay thank you

feral moon
tiny wind
#

Hellloo, my enemy's projewctlie only goes on one direction, anyone know whats wrong?
heres the script

private void RangedAttack()
{
    cooldownTimer = 0;
    darkballs[FindFireball()].transform.position = darkpoint.position;
    darkballs[FindFireball()].GetComponent<EnemyProj>().ActivateProjectile();
}

and this is ActivateProjectile

public void ActivateProjectile()
{
    hit = false;
    lifetime = 0;
    gameObject.SetActive(true);
    coll.enabled = true;
}
tiny wind
#

no, theyre just the ones that are responsible for activating the projectile

echo ruin
tiny wind
#

oh wait yeah, here

private void Update()
{
    if (hit) return;
    float movementSpeed = speed * Time.deltaTime;
    transform.Translate(movementSpeed, 0, 0);

    lifetime += Time.deltaTime;
    if (lifetime > resetTime)
        gameObject.SetActive(false);
}

forgot abt this one

echo ruin
#

So you'd have to have something check whether you're facing left or right

#

So if you're facing left, you just reverse the X value

#

Which you can simply do by adding - before movementSpeed

#

transform.Translate(-movementSpeed, 0, 0);

#

Like so

tiny wind
#

alright, ill try that, thanks

echo ruin
#

Assuming the Update() is the code for the projectile, of course

grand snow
#

movementSpeed * (left ? -1f : 1f)

tiny wind
#

is there a seperate Input thing for a mouse pad?

#

wait is it called a mouse pad?

verbal dome
#

trackpad?

#

I think mouse pad is what you rest your mouse on

tiny wind
tiny wind
sleek flare
#

Quick question, I can't find anything about this on the docs, but when I was messing with WaitForSeconds, vscode suggested WaitForSecondsUnit as well, which I can't find anywhere in the docs, and I tried looking it up and couldn't find anything. Does anyone know what that is used for?

verbal dome
#

That's not a built in thing

verbal dome
#

If it exists then it's from one of your scripts or packages

naive pawn
#

this is most likely not what you want

#

i just googled WaitForSecondsUnit lmao

verbal dome
naive pawn
sleek flare
#

That didn't show for me either, but cool, thank you

verbal dome
#

Checked 5 pages and still won't show up 🤔

naive pawn
#

have you tried adding quotes

verbal dome
#

Doesn't help

#

Ohh it auto corrects it to "waitforseconds unity" automatically 🤦‍♂️But doesn't change the text field

naive pawn
sleek flare
#

I'll double check if anything references it in any way, and remove it if not, thanks

naive pawn
sleek flare
#

Alright, also probably a really dumb question, does a while loop finish the current loop if the variable its running against is changed? ie

bool run = true;
int x = 0;
while(run) {
  p("1");
  p("2");
  if(x == 10) run = false;
  p("3");
  p("4");
  x++;
}

public void p(string s) {
  Debug.Log(s);
}
#

Or does it cut immediately?

naive pawn
#

i mean. you have all that written out, tryitandsee

feral moon
naive pawn
#

you can try in like c# online stuff

sleek flare
#

... I didn't want to try it in my project, as it's semi broken... And forgot that online compilers were a thing XD oops

naive pawn
#

but the current loop runs until completion. while doesn't know what variable it has, it just has a condition that it checks at the end and goes back to the start

sleek flare
#

Thanks

naive pawn
#

while is just shorthand for if goto

#

all control flow statements can be decomposed to if+goto, frankly
so if you understand that, you can figure out how any control flow statement works

#

(disclaimer: you should not use goto.)

buoyant finch
#

hello so my tilemap for solid objects has a composite collider with polygons but in some places polygons are not generated and my player doesn't collide with them pls help

naive pawn
feral moon
naive pawn
#

you didn't show ImageIcon
wow im blind sorry one sec

sleek flare
#

Does anyone know a online c# compiler that supports unityengine code?

naive pawn
#

you could copy the relevant types/methods in directly

#

or write dummy placeholders with appropriate signatures

naive pawn
feral moon
naive pawn
#

TextMeshProUGUI is not bool

#

you can't do that

#

that doesn't even make sense, what are you trying to achieve by doing that?

naive pawn
#

i have no idea what you're trying to do

feral moon
#

is it possible to make a textmeshprogui bool function?

naive pawn
#

that doesn't make sense

#

what are you trying to achieve as the end goal here?

burnt vapor
#

Are you asking for enabling/disabling it? Setting a boolean value makes no sense here

naive pawn
burnt vapor
#

Components always have an enabled field if that's what you want

feral moon
burnt vapor
#

So enabled field

feral moon
#

when the protected override void HighlightLogic is in effect

naive pawn
burnt vapor
#

Or SetActive is also something you might want to check

feral moon
#

I want to make it so that when HighlightLogic logic is running, then distancetext becomes invisible.

feral moon
burnt vapor
feral moon
#

Maybe you can help me with this?

feral moon
naive pawn
#

show the actual code you used

feral moon
sleek flare
#

I'm trying to make a timer for a incremental game that will update the timer when the time is upgraded on it's own, will this work?
(Sorry for all the code questions, the class is still a complete mess as I'm not done creating everything needed inside ^^;)

public int x;
public float time;
public void Init(string[] args) {
    x = 0;
    time = 1;
    StartCoroutine(Tick(time, true));
}
    
public IEnumerator Tick(float time, bool run) {
    while(run) {
        yield return new WaitForSeconds(time);
        Console.WriteLine("Waiting: " + time);
        if(x == 10) UpdateTick(run);
        x = x + 1;
    }
}
    
public void UpdateTick(bool run) {
    run = false;
    time = 0.5;
    StartCoroutine(Tick(time, true));
}
burnt vapor
#

They should be false

naive pawn
feral moon
burnt vapor
#

Put a log message in them and see what the boolean's value is

burnt vapor
#

There are better ways, but a coroutine generally gets the job done

naive pawn
#

you have an infinite loop.

sleek flare
#

Crap. Thank you, and Fuse, how would you do it then?

#

And the class is full of errors as I'm implementing too many things at once, so can't test it without removing a lot of half finished things ^^; Sorry

naive pawn
#

do you need to do something each time interval? if not, why not just wait 10 * time

burnt vapor
# sleek flare Crap. Thank you, and Fuse, how would you do it then?

If this is supposed to be a timer that runs a certain amount of time, you could just keep a "target timestamp" variable and have an Update method check Time.time until it passed that timestamp. When that happened, call UpdateTick or whatever would invoke the behaviour after a timer and update the timestamp

#

The documentaiton of Time.time has a very good example

naive pawn
#

also x seems very weird there. it's never reset back to less than 10

#

so the if will only ever run once

#

i'd probably just opt for a for there instead of a while

#

oh also Console.WriteLine wouldn't work in unity.

naive pawn
#
public IEnumerator Tick(float time, int cycles) {
  for (int i = 0; i < cycles; i++) {
    Debug.Log($"Waiting: {time} ({i})");
    yield return new WaitForSeconds(time);
    // do per-tick thing
  }
  UpdateTick();
}
#

honestly UpdateTick might not even be necessary, you could just handle it all in a single loop

sleek flare
#

It's cause it was edited to work without context from the class.

Basically it's the game loop. This timer updates any changed strings, checks if things can be unlocked, does passive energy generation, handles updating the cost of the item when its bought.

naive pawn
#

wrong person lmao

burnt vapor
#

Ugh, this is why threads exist

#
public class Example : MonoBehaviour
{
    private float _nextTick = 0.0f;
    private float _interval = 5.0f;
  
    void Awake()
    {
        _nextTick = Time.time + _interval;
    }

    void Update()
    {
        if (Time.time > _nextTick)
        {
            _nextTick = Time.time + _interval;

            // Put your logic here
        }
    }
}

Here's a basic example of how you can use Time.time here
@sleek flare

#

Preferably you would split this from the monobehaviour

naive pawn
burnt vapor
#

And also, if you had to tie a visual indication of the time left, you can just get the difference _nextTick - Time.time and use the result in some progress bar for example

#

And lastly, if it matters to you, this is very multiplayer friendly since you just need to inform users of the next timestamp in most cases

sleek flare
#

It's unfinished, but heres the entire class. There are some references outside the class, but mostly its just actual objects assignments to variables.
https://pastebin.com/dHawze5S

burnt vapor
# feral moon What should I do?

See the message I posted below them. I also linked a site explaining how to log values. You need to make sure the method is reached at all, and the boolean you pass truly set it to false

sleek flare
#

The timer basically just manages how often the different strings showing you information are updated, and how often you gain energy (by delay)

naive pawn
#

Round(((5*(tier+1))*((tier+1)*1.2)))
this could definitely be simplified

#

it's equivalent to (tier+1)*(tier+1)*6

#

or Mathf.Pow(tier+1, 2)*6

sleek flare
#

I'll try using the ones you suggest

naive pawn
#

i just reduced the expression you had

#

you have way too many parens there lol

sleek flare
#

Yeah

naive pawn
#

btw, exponential and quadratic are different

#

what you have there is quadratic

#

you might want to try something like Math.Pow(1.5, tier), for example (for exponential)

sleek flare
#

That's what I meant.. I think? I think I didn't do that one cause it grew out of control too quickly

naive pawn
sleek flare
#

Fair!

naive pawn
#

exponential is a^x for some real a>1
quadratic is x^2

#

(of course with constants and lesser terms as desired)

buoyant finch
#

hello so my tilemap for solid objects has a composite collider with polygons but in some places polygons are not generated and my player doesn't collide with them pls help

frigid sequoia
#

Is there a way to like make that the logs just show the the last print for a source?

#

In like, not collapse all that are the same, cause they are showing updated data, I just wanna see just the most recent one

rocky canyon
# frigid sequoia In like, not collapse all that are the same, cause they are showing updated data...
    public static void ClearLogConsole()
    {
#if UNITY_EDITOR
        System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly(typeof(UnityEditor.SceneView));
        System.Type type = assembly.GetType("UnityEditor.LogEntries");
        System.Reflection.MethodInfo method = type.GetMethod("Clear",System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
        method.Invoke(null,null);
#endif
    }```
```cs
ClearLogConsole();
Debug.Log("NewInformation);```
swift crag
#

I'm not aware of a way to remove just some items from the log

#

You may want to use OnGUI to display a value in the game view instead

rocky canyon
#

yea, me neither.. i wasnt even sure u could clear the console at all..

swift crag
#

If you want to display a variety of things, you can do something like this

rocky canyon
#

but someone figured it out.. and i had to try it for myself. but reflection..

swift crag
#
public class DebugDisplay { 
  public event System.Action DrawDebug;

  void OnGUI() {
    GUILayout.BeginVertical();
    DrawDebug?.Invoke();
    GUILayout.EndVertical();
  }
}

Subscribe to DrawDebug and run more GUILayout methods in the subscribed methods

#

e.g. GUILayout.Label("Here is my value: " + value);

rocky canyon
#

now imma remove it b/c i dont like code messing with the unity editor assembs

frigid sequoia
#

Well, it would be amazingly usefull for a log like this

rocky canyon
swift crag
#

the debug manager draws a checkbox every time you yield an IDebug and keeps track of which ones are enabled

rocky canyon
#

$"> {this.gameobject} is trying to attack from {Vector3.Distance..}; needs {stats.attackRange}"
why aren't u using string interpolation btw?

rocky canyon
#

i always see u mention them here and there

#

I plan on making another custom attrib today..
[DebugValue] private float ValueToWatch;
it'd make it read-only w/ a highlight in the inspector 🙂 🤞

swift crag
#

another useful bit:

#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;

namespace Pursuit.Singletons.Prefabs
{
    public class DebugDrawer : SingletonPrefab<DebugDrawer>
    {
        private readonly List<Action> actionList = new();
        private int lastFrame = -1;

        private void OnDrawGizmos()
        {
            foreach (Action action in actionList) action.Invoke();
        }

        [Conditional("UNITY_EDITOR")]
        public void RequestAction(Action action)
        {
            if (Time.frameCount != lastFrame)
            {
                actionList.Clear();
                lastFrame = Time.frameCount;
            }

            actionList.Add(action);
        }
    }
}
rocky canyon
#

or maybe a little icon next to it.. havent thought it all the way thru yet

swift crag
#

I used this while debugging a very nasty sub-frame problem

#

I was using something before it got updated, so I was off by a frame

#

I needed to be able to view the position of something at several points during the frame

#

so I couldn't just display it in OnDrawGizmos

rocky canyon
#

is this basically a in scene Toast type thing?

frigid sequoia
#

Well, I am getting this, and it's not as usefull as it could

rocky canyon
#

i've already shown u how u could clear the console b4 each log

swift crag
rocky canyon
#

and fen gave alternatives too

swift crag
#

i do want to add a toast system

#

Something is creating script errors!

rocky canyon
#

positioning is my main issue..

#

i can do it.. but it takes so much trial and error lol

swift crag
#

vertical layout group

rocky canyon
#

oh, i have an in-game one that uses a layout group..
but im talkin more of just a simple Debug type toast system. that would popup from the bottom..
stay a bit and then disappear

swift crag
#

tick "use child scale" to let them transition in and out too

rocky canyon
#

i'll see what i can't manage, i do feel like today should be an editor day 🙂

buoyant finch
#

hello so basically in my tilemap some tiles do not have polygons in composite collider 2d pls help someone

rocky canyon
buoyant finch
rocky canyon
#

ah, ok.. thats what i wasn't sure of..

#

can u show us a screenshot?

#

what is it ur generating? side/scroller?

buoyant finch
#

ye sure

buoyant finch
rocky canyon
#

thats odd..

buoyant finch
rocky canyon
#

im curious.. can u quickly put the player beneath those bottom colliders and see if u can walk thru them the other direction?

rocky canyon
#

nvm..

#

do all the walls have the same Z position?

buoyant finch
rocky canyon
#

if that makes sense..

buoyant finch
buoyant finch
forest zodiac
#

Any idea why my char isgrounded when on default unity plane with the whatisground layer but when on a cube created using probuilder isgrounded always returns false?

rocky canyon
#

does the probuilder cube have the same layer as the plane?

forest zodiac
#

yup

rocky canyon
#

then some follow ups would be.. does this issue happen with other probuilder shapes?

#

are there any errors in the console or anything that may be breaking the logic?

#

i use raycasts for my ground-check and it seems to be working fine with probuilder.. let me test again to make sur

forest zodiac
#

this is the cube

#

the console has no errors, let me try creating another probuilder shape real quick

ashen frigate
rocky canyon
rocky canyon
# ashen frigate

im way outside my wheel-house w/ inputs but could u just use two different canvas objects?

forest zodiac
#

created another cube, same results but then i tried creating a custom shape and it worked as intended

rocky canyon
#

are u stretching the cube down into a plane?

#

might have something to do with the scaling, as i previously thought.. but then again im just spitballing

#

if it works for a plane, and works for some other shape, i think we can assume its not the logic..

forest zodiac
#

i do stretch it but not enough to be a plane i would say

rocky canyon
#

what happens if u toggle "Convex" on the collider?

forest zodiac
#

same results

ashen frigate
rocky canyon
rocky canyon
#

instead of its default MeshCollider

#

ps. || learn blender, you won't regret it ||

forest zodiac
#

same results :/ that being said theres something i forgot to mention, if i move around im able to jump because for some reason in a few frames the isGrounded variable is set to true and quickly becomes false again so with good enough timing i can do a jump, if i stay still then it just remains false forever. Also heres the script in case it can help solve the issue https://paste.ofcode.org/GYj2M8KGkwnh99NPjg8vpp

rocky canyon
#

ahhh, that Does sound like logic problems

#

0.01f

forest zodiac
#

i just dont understand how it being a cube changes the outcome of the ray

rocky canyon
#

i think u should use more of a margin here

#

i use .2f

#

.01 sounds ridiculously small imo.. its probably just getting inconsistencies

forest zodiac
#

alright, let me try

#

same outcome, the reason why i changed it to begin with was to prevent a second jump before the capsule touched the ground

rocky canyon
#

ya, but i dont think .01 would be enough..
especially if ur using something like a CharacterController..

#

like here, when u start the game.. it sorta hovers a bit.. gotta compensate for that.. either w/ a longer raycast or a smaller Skin thickness

#

that being said.. if ur having issues w/ the raycast i would either

  • use gizmo's to visualize ur raycast so ur not just doing guesswork.. or
  • use alternatives such as SphereCast, Overlapsphere, CheckSphere, etc
#

theres soo many different ways to do ground checks i couldn't even think of em all

forest zodiac
#

yea ill try the gizmos, was looking for a way to visualize it but couldnt quite get there until i saw your code snippet

rocky canyon
#

a raycast is probably the least Accurate imo

forest zodiac
#

what would you recommend instead

rocky canyon
#

b/c theres times when u'd need to compensate. like on a slope for example.. u'd need to cast farther than u would if u were standing flat

#

i like to use raycasts.. but i use an Array of them.. making a circle around the bottom of the player

#

i see lots of ppl using OverlapSphere tho

rocky canyon
forest zodiac
#

im afraid im not cool enough to know what those stand for 😔

rocky canyon
#

rigidbody or character controller

forest zodiac
#

rigidbody

rocky canyon
#

the reason i asked is because a character controller comes w/ a built-in groundcheck already

forest zodiac
#

oh, interesting

rocky canyon
#

Rigibodies are more powerful but harder to work w/

#

i used this one while i was learning.. that way i could focus on other things..

#

just mentioning.. not suggesting u use a third-party one if u really wanna build ur own..

#

but a Controller is a very important step.. and they take time to get right

#

then u can figure out which one u want.. and search up better sources

forest zodiac
#

thanks for letting me know, ill check it out and then decide from there

rocky canyon
rocky canyon
forest zodiac
#

awesome, thanks 👍

timber tide
#

CC is pretty bad ;)

#

kinematic rigidbody if you want custom physics without being bound to a single collider type

#

The selling point on that site is that it does decent climb detection for stairs, but the sloping is half-arsed

rocky canyon
#

yessir..

#

always need fine-tuning those slopes

timber tide
#

I just hate the capsule collider as a character body because it will slowly creep off ledges

rocky canyon
#

lol.. funny u say that.. that was the most challenging thing I did..

#

i now have logic that kinda shoves u off the side when u get too close to it

#

LedgeSlip.cs

timber tide
#

lol yeah im bias on that. I mean it's done for you with CC but if you wanted a bit more control just do rigidbody kinematic

#

CC is meant to provide some template to use for custom physics, but even the template itself isn't always the behaviour you want

rocky canyon
#

purchased it before the KCC was as popular as it is now

#

i dont even remember seeing the KCC until way after

timber tide
#

it really should have a set of behaviours for things like slopes and stuff like moving platforms if it wants any sort of identity

rocky canyon
#

i dont understand why they havent done something like this for the CC yet

#

slopes
a better groundcheck
and moving platforms would make it much more approachable

timber tide
#

Probably just expect people to use KCC, but I feel like they should change all the Unity templates over to using it instead

ripe shard
rocky canyon
#

ya, i always try to explain "if u just want a controller to focus on other things" when i suggest it

#

its definitely not for the faint of heart.. pretty involved when u peep at the code 😄

timber tide
#

The CC examples I feel are just as verbose as KCC

#

but there isn't really a general abstracted version of KCC so you may need to decouple some of the logic

lament harness
#

what am i doing wrong

rapid laurel
#

Anyone knows how to make a character jump? in 2d i made this code but it doesnt work

public Rigidbody2D rbd;
public float force;
void Start()
{
    
}

void Update()
{
    if (Input.GetKeyDown(KeyCode.Escape)) { 
        rbd.AddForce(Vector2.up * force, ForceMode2D.Impulse);
    }
}

}

rich adder
#

also !code

eternal falconBOT
rocky canyon
#

might wanna use another key to test ur jump..

#

everytime u try to jump ur gonna unfocus the game-window

rapid laurel
rich adder
#

o ya why tf is it Escape lol

rapid laurel
#

oh waitt

#

im stupid

#

thougth it was space

#

HAHAHA

#

thanks guys

rocky canyon
#

u tripppin me out lmao

lament harness
#

how do i drag and drop a sprite without it trying to make a new animation

rocky canyon
#

u click the little arrow to open up the sprite sheet..

#

select (1) of those and drag it in

#

or just create empty gameobject -> add a sprite renderer and add the sprite to that

lament harness
#

is this only in new version cus why can the guy im following just drag and drop the whole thing in

rocky canyon
#

if its a sprite sheet w/ multiple sprites.. it assumes ur trying to make an animation w/ all of them

lament harness
#

maybe this guy cut it up

#

for us

#

to use

#

o nvm

#

nvm idk

rocky canyon
#

when u select something check the inspector..

#

one says "Sprite" one says "Texture2D"

lament harness
#

ye

crisp moon
#

whats a good way to come up with a game ideas as a beginner?

rich adder
rocky canyon
#

just start building stuff.. find the fun... then iterate on that

rich adder
#

eg , what happens if you add guns to a game like flappy bird , besides pipes maybe add turrets and stuff you can shoot around

crisp moon
rich adder
crisp moon
ashen frigate
#

can i get help ?

rich adder
#

maybe?

ashen frigate
#

@rich adder

rich adder
ashen frigate
#

im tying to do double cursor for 2 controlers

#

so they could pick 2 bottons in the same time

rich adder
#

where is the instantiating part

ashen frigate
#

instantiating?

#

what do you mean by instantiating

rich adder
#

idk how are the cursors spawning ?

ashen frigate
#

im using player input manager

#

with triger input its spawn a clone prefab

rich adder
#

no idea sorry, I don't know enough about InputSystem yet to know how virtual cursors work

ashen frigate
#

tnx anyway

echo kite
echo kite
rapid laurel
#

how do i move a canvas?, my rect transform have everything blocked

naive pawn
forest zodiac
#

@rocky canyon i checked out more about the different ways to implement movement in unity and ended up choosing a dynamic rigidbody, i ended up fixing the previous bug and now the groundchecks are flawless, thanks for the guidance 👍

rocky canyon
#

np.. good luck on ur journey 🙂

grave rain
# echo kite

Are you familiar with how to add a breakpoint and all that good stuff?

grave rain
# echo kite no

You click on the left hand side of the numbers in VS, and it adds a red circle

#

this makes it into a break point

#

This means when you press play, and Unity hits that line of code, it will stop the game and it should show yout he state of said code

#

During that time, you can also right click your variable and add it to a "Watchlist" - and when you do add it to a watchlist, you'll see it in your Watchlist directory

#

what you're looking for here is to see if your enum, ShootingMode is always the sameShootingMode

#

Now - if you don't feel like doing all that, you can also put in a Debug.Log($"My Enum mode is {ShootingMode}");

grave rain
# echo kite

That is not where you put a line of code in a class.

grave rain
#

That is a basic C# programming 101 know-how

grave rain
echo kite
grave rain
grave rain
echo kite
#

i never needed it

naive pawn
grave rain
# echo kite i never needed it

I'm sure you didn't since you are used to Roblox. but Unity is not Roblox. You DO need to know C# if you intend to use Unity

#

well - intend to use it without trouble anyway

echo kite
#

in unity

naive pawn
#

you need it now

grave rain
unreal sluice
#

Why you guys be so hostile, teach him

echo kite
naive pawn
#

buddy you gotta stop being overconfident

unreal sluice
#

💀

grave rain
# unreal sluice Why you guys be so hostile, teach him

We're trying. But he's saying he doesn't need to learn Unity Learn or anything because he knows Unity VERY well. But then he doesn't actually know it and it's making it hard.

He basically needs to 100% hand holding

naive pawn
#

your stubbornness to learn is gonna get you nowhere

grave rain
# echo kite 1 and this

alright well - anybody working with Unity in the long run will require C#. There's no way around it. Unless you hire a programmer of course.

But if you intend to do it yourself, you're going to need to learn it. That's where UnityLearn will come in

echo kite
#

i learn c#

grave rain
grave rain
echo kite
naive pawn
#

it really doesn't take long

#

it just takes effort and willingness

grave rain
# echo kite by the time i do that u will leave

heh. Well you don't learn C# in a single day. And also - that's just how Discord works.

That's why I am strongly encouraging you to go to Unity Learn. It's always there. So no matter who is on the server or not, you'll have a resource.

naive pawn
#

you do

#

everyone here has gone through it

#

it's a great resource

grave rain
dusky bough
#

i am new to making 3d games, and i cant get my movent system working, can someone help?

naive pawn
#

buddy, we're not gonna cater to every tiny question when you lack basic knowledge

#

you misidentified gameobjects just earlier

#

go do fundamentals

#

if not to learn, to at least communciate effectively

naive pawn
#

you said you had multiple "same" gameobjects when you clearly did not

echo kite
#

cloned is same

naive pawn
#

they are not the same game object

#

they are instantiated from the same one, but they aren't themselves, the same gameobject

#

that's simply just a misunderstanding you have

grave rain
#

yeah sani look - at this point I can't help you because you don't want to actualyl listen to our advice.

I will help you when you go through the lessons on Unity Learn. OR - I will help you if you pay me money to tutor you one on one (which I doubt you want to pay).

So at this point I'll wish you good luck, since you're too stubborn to actually learn

echo kite
#

when i did it it didnt work

naive pawn
#

I don't mean to belittle you, I'm trying to make you realize something here.
You've consistently showed a lack of understanding of some fundamentals.
Your lack of knowledge of those fundamentals causes problems in you communicating issues to us, and us communciating solutions to you.

You simply don't know as much as you think you know. You're way too overconfident.

dusky bough
#

can someone pls help with my movement system, i am very new with 3d games

naive pawn
#

clearly not, when you refused to use them

#

You've denied various very useful resources. If you're not willing to accept our help, we can't help you.

#

that's all.

echo kite
naive pawn
#

and the various denial of physics layers because they were the same object

eternal falconBOT
naive pawn
#

we can't help you if we don't know what your specific problem is

echo kite
#

also how do i fix my problem

dusky bough
naive pawn
#

just ask here

dusky bough
#

ok

rocky canyon
#

feel free.. meet us half way and we're all willin to help

naive pawn
echo kite
#

Debug.Log($"My Enum mode is {ShootingMode}");

naive pawn
#
  • where it's used
  • that's not the value i told you to debug
echo kite
#

only him

naive pawn
#

log them right after you calculate them

echo kite
#

how do i do it

echo kite
grave rain
echo kite
grave rain
naive pawn
echo kite
naive pawn
#

because debugging is a skill, a programming concept, not a c# concept

echo kite
grave rain
grave rain
naive pawn
#

if you understood c# structure, you should be able to answer that

echo kite
naive pawn
#

let me be more specific; where do you put statements

echo kite
#

idk

#

where do i

grave rain
#

this unity learn is specific to the C# side

severe onyx
#

Folks, does anyone have any idea why sometimes a game object isn't properly destroyed via Destroy(gameObject)

echo kite
grave rain
naive pawn
# echo kite where do i

inside methods, properties, lambdas, constructors, and static blocks
now which one of those do you have in your code

severe onyx
#

It seems really random. I was calling the function to do this within an animation clip originally so I thought that was just unreliable

grave rain
naive pawn
severe onyx
#

This function lives on the GameObject that's to be destroyed itself

night mural
# severe onyx It seems really random. I was calling the function to do this within an animatio...

are you running into the delay? from the docs:

The object obj is destroyed immediately after the current Update loop, or t seconds from now if a time is specified. If obj is a Component, this method removes the component from the GameObject and destroys it. If obj is a GameObject, it destroys the GameObject, all its components and all transform children of the GameObject. Actual object destruction is always delayed until after the current Update loop, but is always done before rendering.

#

your object will still exist immeidately after calling Destroy() until the end of the frame

severe onyx
#

Interesting

grave rain
night mural
#

you can use DestroyImmediate if you need to do it immediately

severe onyx
#

I mean it already works 95% of the time

echo kite
#

but what do i write to debug it

severe onyx
#

I'll have some food and then revisit the code to test some fixes

naive pawn
swift crag
#

if A does the check after B calls Destroy on itself, then it'll see B as still existing

echo kite
severe onyx
#

B checks on B in its FixedUpdate

swift crag
#

(even though B already called Destroy on itself)

#

Ah, fixed updates do not line up with frames

#

Unity runs the FixedUpdate messages zero or more times at the start of the frame, before Update

severe onyx
#

Changing it to just Update was the first thing I was gonna try

#

But I still don't understand how it's causing the object to be around forever

echo kite
static estuary
# echo kite what do i write to debug

There are 3 debug genders:
Debug.Log("this is some text. hi!"); Debug.LogWarning("this message has the warning icon"); Debug.LogError("something broke in your game. here is a red error.");

echo kite
static estuary
#

what are u building?

echo kite
#

and what do i write that in

echo kite
static estuary
#

I see

echo kite
#

it shoots backwards when i go backwards

naive pawn
#

to debug some variable a, you log the value of that variable around where the use site is

static estuary
#

there's many things that could cause that.

naive pawn
#

ive told you what variables to debug

static estuary
#

yes for example Debug.Log("The value is" + a);

#

with a being your variable

naive pawn
static estuary
#

.tostring?

naive pawn
#

$"text {variable} more text {other variable}" etc

#

.ToString is called stringification

static estuary
#

Oh ok, sorry I'm not familiar with it

whole ivy
#

can someone help me with something?

grave rain
echo kite
whole ivy
#

How would I get the variable isPressed from a script in gameobject ButtonU from a script inside the player?

whole ivy
static estuary
grave rain
# whole ivy wym

there are two unity input sytsems - We'd have to know which one you're using. If you're using 2.0 you probably had to go through some package hijinx and a restart of Unty

whole ivy
#

prob the old one

static estuary
#

@echo kite I can't rly see what part of the weapon is causing the shoot direction problem

echo kite
grave rain
# whole ivy i dont think im using the new one

Okay so what I think you're doing - you hover over a button. Press down - adn you want to confirm if the mouse button was indeed pressed? or youw ant to confirm WHICH UI button you pressed

echo kite
#

i thought bullet hit another one and it ricocheted but i couldnt fix it using collision groups

static estuary
#

sorry, ask someone else because I don't know how to fix. I've seen the script

#

what if you comment out the recoil parts of your script?

#

`IEnumerator ShootGun()
{
//DetermineRecoil();
StartCoroutine(MuzzleFlash());

    yield return new WaitForSeconds(fireRate);
    _canShoot = true;
}`

Just to see what happens

ashen frigate
naive pawn
#

can you click that color inspector

whole ivy
ashen frigate
#

color inspector ?

#

it was red amoment ago

grave rain
naive pawn
#

@ashen frigate not a code question, let's continue in #💻┃unity-talk (just realized now, sorry.)

ashen frigate
#

ohh sry

whole ivy
grave rain
whole ivy
grave rain
grave rain
#

In the UI inspector, add your player to the OnClick slot. Then tell it to fire a "move up" function in the funtion drop-down

whole ivy
grave rain
# whole ivy thanks ill try that

also - as you learn to code, you're going to learn about singleton's. It's not bad to have a GameManager as a singleton in the future, though many might disagree.

If you don't know what I'm talking about, no problem. You'll get there soion

whole ivy
astral falcon
#

you drag the script on it or select the script class name

whole ivy
#

i think i found it

grave rain
astral falcon
#

yep

spiral narwhal
#

It seems to be a Unity API error, right?

#

It refers to this code

        public static T[] LoadAll(string label)
        {
            T[] res = null;
            Addressables.LoadAssetsAsync<T>(label, null).Completed += handle =>
            {
                if (handle.Status == AsyncOperationStatus.Succeeded) res = handle.Result.ToArray();
                Debug.LogError($"Could not load '{typeof(T)}'. Do the references exist?");
            };
            return res;
        }
whole ivy
grave rain
whole ivy
#

oops dyno

whole ivy
#

that is the update function that moves it

grave rain
whole ivy
#
public void MoveUp()
    {
        playerAnim.Play("playerWalkD");
        direction = 0;
    }

this function works but it doesnt move the player (i need to set the moveinput)

astral falcon
#

But the moveinput probably gets overridden by your inputs?

#

so no matter what you do with your button, update will override it

whole ivy
#

Moveinput is created by my inputs

#

and modified by my inputs

#

i was thinking if i could set moveinput with the button

grave rain
whole ivy
grave rain
whole ivy
astral falcon
grave rain
# whole ivy https://pastebin.com/D8nCjBKt

Okay a couple thing.s Do put not these in your Update

            rb2d.constraints = RigidbodyConstraints2D.None;
            rb2d.constraints = RigidbodyConstraints2D.FreezeRotation;

You should put these in your Start method. Fidn them once and done. Right now you have them repeatedly looking for the same things over and over again when it should be a once and done

#

Same thing for your moveInput, etc

#

find them once and be done

whole ivy
#

Alright, I put those in my start method

grave rain
#

and in your Move() you probably want to set your moveInput.y to 1, and that SHOULD drive it upwards.

#

however, that will only ever move it up

whole ivy
#

it seems that the function only happens when the button is released, but it needs to happen repeatedly while the button is pressed

grave rain
# whole ivy it seems that the function only happens when the button is released, but it need...

okay well , you can maken five public void functions, one for each movement, and then one for StopMoving. In those functions, you'll assign your move inputs accordingly. moveInput.y =1, or -1. etc.

I also realized I might ahve guided you wrong (my pardons). You do want to get your GetAxisRaw fucntions in Update, because we want to check every frame from movement. So you'll put this back in Update()

Vector2.zero;

        // Check keyboard input
        if (Input.GetAxisRaw("Horizontal") != 0)
        {
            moveInput.x = Input.GetAxisRaw("Horizontal");
        }
        if (Input.GetAxisRaw("Vertical") != 0)
        {
            moveInput.y = Input.GetAxisRaw("Vertical");
        

Again, sorry about that...
Recommend you use moveInput.Normalize() to keep the movement normalized

grave rain
whole ivy
grave rain
mystic lark
#

Is there a way i can find out what direction/point im looking at? like when im shoothing that i shoot in the derction the player is looking

slender nymph
#

is this 2d or 3d

mystic lark
#

3d

slender nymph
#

presumably the direction the player is looking at is the camera's forward direction so you can just use that

mystic lark
#

yea thanks and woud that be the point im looking at or just a direction lik z x

grave rain
mystic lark
#

cuz what if my camera is looking bettwen x & z?

slender nymph
mystic lark
#

ill try it thanks

grave rain
grave rain
vocal wing
#

can someone explain me why I can't move with this code in a 2D object?


public class PlayerMovement2D : MonoBehaviour
{
    public Rigidbody2D Movement_For_Game;
    public float moveSpeed = 6f;

    private Vector2 movement;

    void Update()
    {

        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");
    }

    void FixedUpdate()
    {

        Vector2 velocity = new Vector2(movement.x * moveSpeed, Movement_For_Game.velocity.y); // Somente altera o eixo X
        Movement_For_Game.velocity = velocity;
    }
}```
slender nymph
#

any errors in the console?

vocal wing
#

nop

slender nymph
#

is the component actually attached to an object in the scene

vocal wing
#

actually when I used debug.log it said that it moved but in the screen it was the same

slender nymph
#

show the rigidbody

vocal wing
naive pawn
#

it's not simulated

#

you probably accidentally unticked that box

vocal wing
#

ty

#

that's true ty so much

late abyss
#

Guess who finally got their audio source problems fixed with their flappy bird game?

unreal sluice
#

how do i fix my objects pivot? Or is it about pivot, whenever i call Transform.position its offset and adding box collider is offset too even tho its centered to 0,0,0

rich adder
#

also you should show the hierarchy when showing such screenshots

unreal sluice
cerulean badger
#

Does the learn website from unity have 2D tutorials? I've searched quite a bit but only found 3D stuff

rich adder
rich adder
#

almost everything 3D translates to 2D the same, Unity is a 3d Engine

#

all that changes is the physics api, and the difference is simply adding 2D at end eg (Rigidbody vs Rigidbody2D)

cerulean badger
#

Ok then, ty

ashen frigate
rocky canyon
#

is the mouse graphic blocking it..

ashen frigate
#

mouse grahic ?

rocky canyon
#

the sprite.

ashen frigate
#

the raycast target is off

#

on the img

rocky canyon
#

oh, well that was my guess.. hmm

#

is the actual mouse position the same as the glove cursor..

#

couldnt u keep it visible during the development of it

ashen frigate
#

anchor is top left

rocky canyon
#

just for sanity sake.. lol i couldnt think of anything

ashen frigate
#

couldnt u keep it visible during the development of it what do you mean like how ?

lament harness
#

Can someone tell me why this doesnt work, Im trying to make it play a jump animation when space is pressed and its not touching the ground layer


     if (value.isPressed && myCapsuleCollider.IsTouchingLayers(LayerMask.GetMask("Ground")))
     {
         myrigidbody.linearVelocity += new Vector2(0f, jumpSpeed);
         myAnimator.SetBool("isJumping", !myCapsuleCollider.IsTouchingLayers(LayerMask.GetMask("Ground")));```
lament harness
rich adder
lament harness
#

ye i did it and its printing

rich adder
lament harness
rich adder
#

the end ?

lament harness
#

behind
myAnimator.SetBool("isJumping", !myCapsuleCollider.IsTouchingLayers(LayerMask.GetMask("Ground")))

rich adder
#

I meant log something useful

lament harness
rich adder
#

log for example !myCapsuleCollider.IsTouchingLayers(LayerMask.GetMask("Ground") in sepearte var

rich adder
lament harness
rich adder
#

you want your player grounded if its face or chest touches side of a wall ?

lament harness
#

its like 2d platformer

rich adder
#

yes but do you know what IsTouchingLayers does?

lament harness
#

doesnt it just return true if its touching the layer i specified?

rich adder
#

it should, but it doesn't care if its feet or some other part

lament harness
#

its just the collider

#

but why does it only return true when i press space

rich adder
lament harness
rich adder
#

is it not touching ground layers mid air

lament harness
rich adder
lament harness
rich adder
#

if myCapsuleCollider not touching ground, is true

#

if it entered the jump then IsTouchingLayers = true. then it becomes false according to you

lament harness
#

i thought it would return false whenever i jumped since its not touching the layer anymore

lament harness
#

u saying istouchinglayer returns true if its not touching the ground?

rich adder
lament harness
rich adder
#

NOT false is true

lament harness
#

that was written in the bool part of the animation

#

so when its false and ur not touching the floor

#

u play the anim so it changes it to true using !

#

right

grave rain
rich adder
lament harness
#

though

#

because i want the jump animation to start playing when im not touching the floor

#

but it just never plays ever

west radish
rich adder
lament harness
#

wait

rich adder
lament harness
#

maybe

#

its because of the exit time

#

or transition

#

duration

rich adder
#

if you don't show how can we know

#

ow ow ow

lament harness
#

sorry i was changing it

#

let me try

#

nvm still doeesnt work

rich adder
lament harness
rich adder
#

no exit time?

#

anyway keep animator window open, select your object with the animator during playmode, see whats happening in the transitions / parameters for animator

lament harness
#

it never even transitions to jumping

rich adder
#

what about the bool?

lament harness
#

the checkmark beside the parameter isJumping doesnt get ticked

rich adder
#

make sure you have the correct animator referenced

lament harness
lament harness
#

oh

rich adder
lament harness
rich adder
# lament harness

ok so the script is on the same object that has this animator you shown?

lament harness
#

which work fine

rich adder
#

but you said log said true

lament harness
rich adder
#

just use a raycast maybe? lol

rich adder
#

you should store values anyway

lament harness
rich adder
lament harness
#

but it did have exit time before i changed it

rich adder
lament harness
#

cus it never even goes to

#

jump

#

i can make it jump if i change some conditions so i think its something wrong with my true and falses

#

if i change myAnimator.SetBool("isJumping", !myCapsuleCollider.IsTouchingLayers(LayerMask.GetMask("Ground")));

and remove the !, it never stops jumping

rich adder
#

or the bool stayed true

lament harness
#

but how

lament harness
rich adder
#

idk but Id read this maybe its important..

It is important to understand that checking if colliders are touching or not is performed against the last physics system update i.e. the state of touching colliders at that time. If you have just added a new Collider2D or have moved a Collider2D but a physics update has not yet taken place then the colliders will not be shown as touching. The touching state is identical to that indicated by the physics collision or trigger callbacks.
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Collider2D.IsTouchingLayers.html

lament harness
#

i think it just stays true

rich adder
#

btw why not just make the jump a trigger instead of bool

lament harness
#

thats y i was confused why it kept returning true whenever i pressed space

rich adder
#

if you use a trigger you don't even need a bool

#

anim.SetTrigger("Jump")

lament harness
#

ive never used that

rich adder
#

bool is useful if you have Falling / or different animation while in air not grounded

rich adder
#

usually jump is a one time thing

#

mine typically go
Jump => Falling => Landed

#

Falling is only isGrounded = false

#

once it goes to true it plays landed animation / state

lament harness
#

i was planning to make double jump cus there was a double jump animation

rich adder
#

thats fine but still

#

I would use a better grounded check method

lament harness
#

ill try follow a tut online bc i dotn know any other ground check methods

lament harness
#

2d

#

platformer

rich adder
#

the most common ones are usually Raycast and such

lament harness
rich adder
#
Vector3 origin = transform.position + offset;
isGrounded = Physics2D.Raycast(origin , Vector2.down, dist, layers))
lament harness
#

i just watched a video on blackthornprod

#

he uses

rich adder
#

yeah overlap circle is good actually

lament harness
#

this guy didnt even explain tho

ruby steppe
#

I JUST WANT THE DARN CAMERA TO FOLLOW THE MOUSE AND ITS GIVING ME AN ERROR 😭😭😭

rich adder
#

better fits a capsule

eternal falconBOT
slender nymph
eternal falconBOT
rich adder
#

@ruby steppe you got some homework todo ✍️

ruby steppe
#

B-but.. where is the error

slender nymph
#

configure your IDE before you can get help

keen owl
slender nymph
#

it's first person view code, they want to rotate the camera by moving the mouse. they just worded it poorly

ruby steppe
#

Someone help me out 😔

keen owl
#

Do what they requested

slender nymph
#

have you configured your IDE yet? that is a requirement to receive help here

ruby steppe
#

I will see myself out to download my IDE
😶

slender nymph
#

you have an IDE downloaded, you need to configure it

rich adder
slender nymph
#

keep the reaction image spam out of here

frosty hound
#

@ruby steppe You can stop now

ruby steppe
#

What did i do ☹️

frosty hound
#

There are no memes allowed here. Thanks.

visual linden
ruby steppe
#

I gotta be an intellectual being?? 😔

#

Jk i am but i suck at csharp..

visual linden
rich adder
ruby steppe
#

I know java and python

visual linden
slender nymph
# ruby steppe I know java and python

if you know java then surely you know how to solve a null reference exception. unless of course you "know" java by having just written Hello World

keen owl
#

This is a dev server specifically for unity and a little of C#, so anything outside that scope probably goes against their rules. Also, java is pretty transferable to C# I heard

ruby steppe
#

But unity script? Im cooked, fried, boiled, sautéed, reverse seared etc..

timber tide
#

Java is 100% transferable

#

better yet, forget Java entirely

#

c# is just better

visual linden
#

I think our default response to someone not having read the rules (because let's be real, who does), should be to let them known they're breaking the rules and gently incourage them to have another look at them.

void thicket
#

There was Java cursed code that can do it

rich adder
keen owl
slender nymph
rich adder
slender nymph
keen owl
#

Yes and java too

ruby steppe
#

Im not built for coding 😔 time to keep studying math 😔

keen owl
#

Kotlin is more modern ig, so yeah

slender nymph
#

can you quit the nonsense spamming and go configure your IDE

ruby steppe
#

How 🤔

slender nymph
rich adder
ruby steppe
#

Alr yall leaving the server now

#

See ya

swift crag
rapid nexus
#

Hey guys, got a dumb question. When I use get axis to get the input it doesnt set the value to 1, instead it gradually increases from 0. This leads my character to take a second before stopping. I dont remember this being a problem before, any ideas?

slender nymph
#

GetAxis includes input smoothing, if you want values that are just -1,0,1 for digital input then use GetAxisRaw

rapid nexus
#

This proble has been killing me, thank you!

buoyant finch
#

hello so my tilemap for solid objects has a composite collider with polygons but in some places polygons are not generated and my player doesn't collide with them pls help

wintry quarry
#

you can edit a sprite's physics shape in the sprite editor.

buoyant finch
#

I know and all of my tiles have physics shape still they aren't shown like no polygons

quartz plinth
#

Hey guys can somebody help me with some coding? you see my player jumps off the first one, but i made the collider extra big. You can see the I land on the platform and then my player wont jump. Probably a problem with my ground check right? im not so proficient, so if anybody has a quick idea, or can give me a Debug,Log Object Grounded code, I would appreciate it so much!

wintry quarry
slender nymph
keen owl
frigid sequoia
#

Is that lane something I can make? Like it would break the for each loop iteration or the whole method?

slender nymph
#

break exits out of the loop, it does not return from the method. are you certain you don't want a continue there instead to just skip to the next iteration of the loop?

frigid sequoia
#

I want it to not count itself if it appears on the list

#

Cause it's basically setting their aggro focus

slender nymph
#

right, but surely you don't want to stop the loop completely

frigid sequoia
#

Oh, so continue skips just one iteration rigth?

slender nymph
#

continue goes directly to the next iteration of the loop

#

break exits the loop

frigid sequoia
#

Great, still this is returning itself anyways, which.... shouldn't if I am breaking the loop early????

slender nymph
#

show how you have determined that

frigid sequoia
#

How have I determined what?

#

That's pretty much the whole relevant code

slender nymph
#

that it is returning itself despite breaking the loop. how have you determined that is what is happening

frigid sequoia
#

Cause it is literally the only possible method that can return a non-enemy target

slender nymph
#

again, how have you determined this

#

do not make assumptions. verify what is actually happening

frigid sequoia
#

This is the only way to set an ally target, like there is no other

slender nymph
#

how have you determined that CalculateClosestEntity is returning itself

frigid sequoia
#

Cause it shows in the inspector??

slender nymph
#

how about instead of relying on what you see in the inspector, you add some logs with some useful information to confirm what is happening

#

because with your current code, it cannot return its own gameobject, that is not possible because the variable would be null at that point if there's nothing else in the list

drifting cosmos
#

is there a best encryption algorithm

north kiln
#

Everything is completely context dependent

#

and in gamedev, there's very little reason to encrypt anything

wintry quarry
drifting cosmos
#

like for saving data

wintry quarry
#

Encryption algorithms have little to do with saving data.

drifting cosmos
#

like save the data file and encrypt it

#

so people dont know

north kiln
#

Why would you want that

drifting cosmos
#

so you cant just edit the file where youre saving data

north kiln
#

that's not a reason, that's your end goal restated

drifting cosmos
#

wdym?

north kiln
#

why don't you want people editing the save file

drifting cosmos
#

im not making an offline game where nothing matters

north kiln
#

Then why would you save anything that mattered on the user's machine

wintry quarry
#

If it's an online game, the custody and veracity of your data should be the responsibility of your servers, not the client device

drifting cosmos
#

well you save it on both

#

im verifying with lambda

wintry quarry
#

There's no encryption scheme that will prevent your players from accessing and modifying data local to their hardware. Rely on something else to prevent cheating.

drifting cosmos
#

thats why im verifying with lambda serverless functions

#

but i still need it for other parts of the game

wintry quarry
#

So then what's the encryption for

drifting cosmos
#

well i have an offline part of the game

#

and i dont want it on a server so im doing some lambda checks but things like position i dont want to have to check every second because its expensive

#

encryption will make it harder not prevent

charred spoke
#

What you are saying doesn’t make sense to me

wintry quarry
#

and if they don't, they don't matter as far as cheating prevention goes.

keen owl
# drifting cosmos its serverless though

You can try the advanced encryption standard library while using an IL2CPP build for further obfuscation, though i’m not sure if AES will give you what you’re looking for

drifting cosmos
wintry quarry
drifting cosmos
#

yeah but the game isnt online its single player the lambda is just some verification

#

thats what i mean

keen owl
wintry quarry
#

Do we care if people cheat in solitaire?

drifting cosmos
#

i mean one part of the game is single player

wintry quarry
#

Cheating is a problem because it ruins the enjoyment of other players. If there are no other players who's enjoyment is ruined, it's not a problem

drifting cosmos
#

its still online its just a part thats not multiplayer

wintry quarry
#

You're contradicting yourself

frosty hound
#

Ultimately, you can't prevent it. So this circle of "it's multiplayer but not" is going to be never ending.

drifting cosmos
#

im not trying to prevent it entirely

frosty hound
#

If you have a portion of your game that isn't multiplayer, it still has to have an internet connection to access the data on the server to prevent modification.

wintry quarry
#

It doesn't really matter what encryption algorithm you use because if your game is able to decrypt it to do gameplay functionality, you must be providing the encryption key. Which means any halfway knowledgable player with Cheat Engine is going to get the key and decrypt the data themselves and do whatever they'd like.

So your game better just not trust any data coming from a client if you want to prevent cheating.

drifting cosmos
#

but you dont need to run a server

wintry quarry
#

I think you're hung up on the technicality of the word "server" here

#

we're just talking about whatever computing resources you have under your control that operate the cloud portions of the game

#

If that's some "serverless" AWS Lambdas or something, so be it

#

the point stands

drifting cosmos
#

i mean theres no server like you would need for say 2 players

echo ruin
#

So one of the players is hosting the multiplayer session?

drifting cosmos
wintry quarry
#

the key goes to the client

#

the client has the key

#

Someone will write a script very quickly that uses whatever the current encryption key is, they won't hardcode it

drifting cosmos
#

well if you cant decrypt a common algorithm the first time it takes time to crack then you can change it like the first time you implemented it right?

#

its not like encryption is completely useless right

wintry quarry
#

When you have the encryption key, you can decrypt whatever you want, very quickly

drifting cosmos
#

but games do use it though right

wintry quarry
#

Very few games encrypt save files

#

And any online game worth its salt is not relying on client-side encryption for anti-cheat

echo ruin
#

Most online games will save data on their own servers. Typically they’ll only save superficial things like keybinds on the users PC

drifting cosmos
#

well i know its not a complete solution but i didnt know it was completely useless

drifting cosmos
#

its not a big deal though