#💻┃code-beginner

1 messages · Page 639 of 1

rocky canyon
#
Vector2 attackOrigin = machetepos.transform.position;
Vector2 directionToHit = (attackOrigin - hitEnemy.transform.position).normalized;
#

this is something like praetor was mentioning

#

excuse my crappy drawing.. but u can just use the positions and subtract to get the direction.. and then just flip it

green copper
#

Would it be better to turn the whole gameobject, or have the wheel be a child of a wheelAnchor game object that doesn't turn?

Also, how could I allow the player to click any point along the wheel, instead of having the "handle" or "top" teleport around to under the mouse? My initial attempt at solving the problem did that, where I used some variation of lookAt

hollow dawn
rocky canyon
rocky canyon
#

but yea praetors idea is better i think as the math is simple

rocky canyon
#

when u collider u know the obj.. soo u can just sub its pos

acoustic belfry
#

so i just have to get the position of the bullet or the player, minus the pos of the enemy, and then put it negative?

wintry quarry
rocky canyon
#

nooo.. u have to subtract here from there.. or there from here..

acoustic belfry
#

...how?

rocky canyon
#

here from there will get a direction opposite

#

transform.position - thattransfrom.position?

acoustic belfry
#

ah yeah, thats what i said, i just forgot to write it

#

so is
get player or proyectile pos
minus enemy pos
negative

rocky canyon
#

then normalize it if u want to use it to multiply any forces or w/e

hollow dawn
# celest ore whats the context?

I'm making a first person game, that script is my fps controller, just want some feedback e.g. - if I'm doing things correctly, what I should change, you should do this instead of that etc.

rocky canyon
#

character controllers are known the best by their owners tbh.. u have more experience in it than anyone else..

acoustic belfry
#

but my question now is, how i can get the player and the proyectile pos from the enemy?

rocky canyon
#

why would u need the player?

green copper
acoustic belfry
#

like
how i can make it get the Position of the Specific proyectile (prefab) that hit it?

rocky canyon
#

what u mean..

#

looks to me ur scripts have the references to each other

acoustic belfry
#

i know how to reference the enemy from the bullets, but not the bullets from the enemy

HOLUP

u mean, also make the position of the proyectile a value, wich i also sent to the enemy

#

like the damage value, but is the position of the proyectile

rocky canyon
#

if u have a reference to a script u can just use it like enemy.gameObject.transform.position

wintry quarry
rocky canyon
#

this is wat basic subtraction looks like.. its not perfect (depending on the collider shape) but its pretty close..

acoustic belfry
#

well thanks :3
i will test if it works

grand snow
#

all components have transform as a property so you dont have to go to gameObject firstly

cold cove
#

how do I make difrent idols based on where my character is facing

grand snow
#

blend tree

grand snow
#

i presume they mean "idle"

chrome wadi
#

different idols animations

wintry quarry
#

ah, idle yeah

chrome wadi
#

idles

wintry quarry
#

idol is like a statue you worship

chrome wadi
#

blend tree is the way to go

wintry quarry
cold cove
cold cove
#

why is it not recognizing serializedfield???

wintry quarry
cold cove
#

why not now

wintry quarry
#

Becasuse your IDE isn't configured

#

!ide

eternal falconBOT
cold cove
#

still not working

rich adder
cold cove
#

one question I dont think this is the reason but where are unity prefrences

rich adder
#

if you dont see this down here, your vsc is not configured

rich adder
#

its also part of the steps in VSC

#

which makes me suspicious when you claimed
"still not working" did you even click the setup steps at all..

cold cove
#

why isnt this working

rich adder
#

because you aren't following the steps

cold cove
#

its not showing visual studio

rich adder
#

then you did not configure it

cold cove
#

for external tools do I need to browse it?

rich adder
#

it shows you exactly the version of VSC you have

#

if configured properly

cold cove
#

I did everything its till not working

high mauve
#

hey can some one help me

rich adder
eternal falconBOT
high mauve
#

i am making a game for my uni project but my 3D models start to rotate on collision

#

while x and z rotation are blocked in rigitbody

#

cant find any thing

#

still confused

rich adder
#

this is a code channel btw

high mauve
#

how to show i have a git repo should i send a link?

#

which channel is correct

wintry quarry
rich adder
high mauve
#

the model is rotating in y axis

wintry quarry
#

so of course it can rotate on the y axis

high mauve
#

but it will not jump then

wintry quarry
#

rotation and position constraints are separate

rich adder
wintry quarry
#

freeze y rotation to make it not rotate on the y axis

#

this won't affect position

high mauve
#

ok

#

thankyou

#

really thank you

#

it was irritating me really

manic dawn
#

@rich adder do you free?

high mauve
#

that do you mean?

#

oh sorry you were asking nav

#

my bad

normal mango
#

hello yall, got a problem with event systems here. line 92 here is supposed to stop the method when i click on ui, but when i select an UI input field in my game with a clickable game object behind it, the logic executes and doesnt stop the method. whats the solution to this?
https://paste.mod.gg/wlautbrzgdbg/0

rich adder
manic dawn
#

kk

#

do you have information about 2d games?

rich adder
manic dawn
#

i just had a problem about chracter moving

#

these my first time on unity and my teachers just joined me to the gamejam

#

i must do that

rich adder
rich adder
manic dawn
#

if u can come private chat i can show with share screen

rich adder
#

no, you can use screenshots here just fine.

manic dawn
#

i dont know my wrong

#

why?

rich adder
# manic dawn why?

because private chat requires more commitment to a problem than I feel like devoting to lol

#

You can post here, others can chime in and help

manic dawn
#

nope thanks for help

rich adder
#

goodluck then

cosmic dagger
# manic dawn why?

Post screenshots of your editor if we need to see Inspector values and post any related !code using links from the bot . . .

eternal falconBOT
frail wagon
#

Hello i have imported a bundle of assets i have already done the “Render Pipeline converter” except that the water uses a shader and not the URP. how can i use the shader that the person has used because for now my water is pink. ? thanks

rich adder
#

Custom shaders cannot be converted automatically

#

You need to find out whats the equivalent functions from BiRP shader and convert it yourself or find another one compatible with the render pipeline you are using

frail wagon
cold cove
#

how do I make the wand spright flip ?(why is my code not working)
ising UnityEngine;

public class WandController : MonoBehaviour
{
public Transform player; // Reference to player
public float distanceFromPlayer = 1.5f; // How far the wand stays from the player

private float horizontal;
void Update()
{
    FollowMouse();
    horizontal = Input.GetAxisRaw("Horizontal");
}
private bool isFacingRight = true;
void FollowMouse()
{
    if (player == null) return; // Prevent errors if the player is missing

    // Get mouse position in world space
    Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    mousePosition.z = 0f; // Ensure it's in 2D space

    // Find position between player and mouse
    Vector3 direction = (mousePosition - player.position).normalized;
    Vector3 wandPosition = player.position + direction * distanceFromPlayer;

    // Move wand to the calculated position
    transform.position = wandPosition;

    // Rotate the wand to face the mouse
    float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
    transform.rotation = Quaternion.Euler(0, 0, angle);
}
  private void Flip()
{
    if (isFacingRight && horizontal < 0f || !isFacingRight && horizontal > 0f)
    {
        isFacingRight = !isFacingRight;
        Vector3 localScale = transform.localScale;
        localScale.x *= -1f;
        transform.localScale = localScale;
    }
}

}

eternal falconBOT
cold cove
rich adder
#

or how about make it properly legible so you can get help better?

cold cove
#

okay

#

here you go

rich adder
cold cove
#

the wand sprite isnt flipping

rich adder
#

where do you call Flip

wintry quarry
#

(they don't)

acoustic belfry
#

i dont know what i did wrong...but the shards aren't shoot, they just fall off
Enemy:

if (health <= 0)
{
    GameObject RifleRotoFragments = Instantiate(RifleRoto, proyectilposition.position, Quaternion.identity);
    Vector3 direccionFragmentos = (transform.position - attackposition.position).normalized;
    Rigidbody2D rb = RifleRotoFragments.GetComponent<Rigidbody2D>();
    if (rb != null)
    {
        rb.linearVelocity = direccionFragments * 10;
    }```

proyectile:
```cs
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.transform.TryGetComponent(out EnemyBase enemy))
     {
         enemy.TakeDamage(riflebulletdamage, 1, transform);
         Destroy(gameObject);
     }
 }```
rich adder
acoustic belfry
#

player's melee:

private void MeleeAttack()
 {
     // Cast a ray to detect if an enemy is in range

     Vector2 MacheteRange = new Vector2(attackRange, attackRange);
     Collider2D hitEnemy = Physics2D.OverlapBox(machetepos.transform.position, MacheteRange, 0f, demons);
     Collider2D hitProyectile = Physics2D.OverlapBox(machetepos.transform.position, MacheteRange, 0f, proyectile);



     // If an enemy is detected, deal damage
     if (hitEnemy != null)
     {
         if (hitEnemy.TryGetComponent(out EnemyBase enemy))
         {
             enemy.TakeDamage(meleeDamage, 0, machetepos.transform);
         }
     }```
acoustic belfry
wintry quarry
cold cove
rich adder
# acoustic belfry what you mean?

Part of fixing a problem is to narrow down to where the issue is.. You can't do that if you don't verify your code is doing what you expect it to do. Logging the values, breakpoints etc. these are tools developer use to narrow down those unexpected values

cold cove
#

wait how do I call it

#

Meant to say when

wintry quarry
#

Where di you get the code from?

#

did you not write it yourself?

rich adder
#

this looks "AI" generated sadly

wintry quarry
#

If you wrote it you would have had some idea when you would call it

acoustic belfry
#

but i mean, in theory it should work, cuz literally in the same part where it damages and the corpse falls, its the same that should make it yeet

#

the only place i have to look is if it has a rigidbody...wich i added, but i will check anyways

rich adder
cold cove
acoustic belfry
#

holup, i think i found the issue, but not the awnser

it cheks if the object has a rigidbody, wich it doesnt, why?, cuz is a collection

rich adder
#

finding the issue is part of fixing the problem

acoustic belfry
#

are all the shards of the enemy put inside a gameobject, all of the objects have a rigidbody but the collection
but my question is...How do i make the enemy interact with the children's rigidbodies instead of the gameobject rigidbody

rich adder
#

google Get / Interact with Component in Child Unity

acoustic belfry
#

ok

noble forum
#

anyone wanna try out my game its only 7mb i need feedback

rich adder
#

read the pinned post as well how to post

noble forum
rich adder
noble forum
rich adder
cold cove
#

guys why is my dash going down instead of left and right?

#

private void dash()
{
horizontal = Input.GetAxisRaw("Horizontal");
Vector2 movement = new Vector3(horizontal, 0f) * 100f;
rb.linearVelocit
}

#

In udpate its constantly checking for button pressed

#

and acording to it calling the function

#

nvm I am stupid

polar dust
#

the odds of somebody wanting to go through that effort, unless youve got something incredibly unique and one of a kind, is quite low

#

besides, if you proved in court that somebody profited off stolen code, there will only be one thing on my mind

#

🤑

eternal needle
# polar dust without adding layers of obfuscation to your project, anyone who is dedicated en...

Nitpicking a bit here although my opinion is the same. Obfuscation isnt security, people can decompile it and do whatever they want if its on their system. Assets will be taken but such is life.
There are also tons of clones of games, and it's not so easy to go after them. I dont know what smaller companies do but I doubt most caught cases go to court. It's probably reported on the websites which it was uploaded and that's all

polar dust
cold cove
#

how can I determen the way my character is facing making a 2D game?

polar dust
cold cove
#

what does it return?

rich adder
#

transform.forward would not be it

polar dust
#

when your character walks around, and you select their gameobject, does the gizmo arrow change direction?

polar dust
cold cove
rich adder
cold cove
#

could transform.localScale.x work?

polar dust
rich adder
#

Unity 2D would be tranform.right = left/right transform.up /updown

polar dust
#

brain fart 😆 been a long day

rich adder
cold cove
rich adder
# cold cove

ok yes but what do you want to do with the direction?

#

because most of the time you're the one determine which way is what

cold cove
#

making a blink

rich adder
#

a blink? idk what that is

cold cove
#

like a quick dash but a teleport

#

where you can go through objects

#

its curently working but only in right

rich adder
#

well right now transform.right is technically forward

#

depends how you flip the player

cold cove
#

yeah right is forward

rich adder
#

if you only flip the sprite, you are technically still facing "right"

cold cove
#

but how can I use thath in a if statment

rich adder
cold cove
#

okay

#

wawit I have an idea

#

I gota try

#

I fixed it

rich adder
#

here is a basic one

Vector2 direction = transform.right;
if (direction.x > 0){
    // Facing right
}
else if (direction.x < 0){
    // Facing left
}```
cold cove
#

used transform.localScale.x > 0

rich adder
#

sure scale can work too

#

its much easier if you make a boolean

cold cove
#

I g

#

but this works and I will not touch it dont wana acidently mess it up

rich adder
#

nothing hard about..
bool facingRight
facingRight = transform.localScale.x > 0

#

if you need to do more logic based on facing direction typing transform.localScale.x > 0 every time is creating more work

cold cove
#

This is my blink method for some reason the trail isnt appearing

#

this is how I defined it

#

[SerializeField] private TrailRenderer tr;

slender nymph
#

there is effectively 0 time between when you set the trail renderer to emitting to when you set it to not emitting. and the only line of code that runs in between those two lines is you setting the position. the trail renderer does nothing in that time

cold cove
#

still I just need a line in betwen the starting and dthe ending positoin

#

also how could I fix it

jolly moat
#

How can I get an enemy’s sprite renderer to pulse red once per hit? I know how to make something pulse indefinitely using the Update() and Pingpong() methods. I’m not sure how to do it for just one pulse though. Any tips?

eternal needle
tulip relic
jolly moat
#

I was planning on changing the spriterenderer’s color gradually between two color values. When the player hits, enemy goes from normal color to red back to normal, end color change there until hit again

eternal needle
tulip relic
#

I prefer the look of instantly turning red and fading back, though.

proper plank
#

is there a nice way to get coroutines not to lag

#

working on a grid streaming system and every time i need to load a new grid, it lags

#

if i added yield return null after every single line it actually works great but that's definitely awful practice 😭

#

apologies if this is vague i can give more info if needed lol

ember tangle
#

I'm having some issues with AddForce() being a bit inconsistent.

Force is added here, in a function only called in FixedUpdate():

{
    if(active) rigidbody2D.AddForce(this.transform.up * attack.projectileSpeed, ForceMode2D.Impulse);
}```

when a projectile is spawned, attack.projectile speed is set to a scriptable object variable
``` public void SetProjectile(Entity origin, Vector3 target, Attack attack)
 {

     active = true;

     this.attack = attack;
     this.gameObject.tag = origin.gameObject.tag; // used for making projectile not collide with entity that fired it
     spriteRenderer.sprite = attack.projectileSprite;

     transform.position = origin.gameObject.transform.position;

     direction = target - transform.position;
     transform.rotation = Quaternion.FromToRotation(Vector3.up, direction);
     transform.Translate(Vector3.up * (origin.type.size * 0.6f)); //creates projectile slightly in front of entity
 
 }```

force is removed here once the projectile hits a wall.:

public void Halt()
{
this.rigidbody2D.linearVelocity = Vector3.zero;
this.rigidbody2D.angularVelocity = 0f;
}```

for some reason, every 20 or so times that a projectile is activated, that projectile moves extremely fast until reset.

frosty hound
proper plank
#

yeahhh that's what i was thinking it was gonna be

#

it's not even super intensive though like it still runs fast, but just slow enough to cause a slight hitch when going over grid boundaries

#

isn't the whole point of coroutines for it to be "async" in a sense though?

frosty hound
#

It's not multithreaded if that's what you mean

proper plank
#

think i've got a misunderstanding of coroutines then

#

initially i thought they were like separate threads that do work without touching the main "get everything done for update in frame" task

#

i think my issue is stemming from the coroutine trying to load everything in one frame, so it halts to finish that process

#

would make sense why adding yield return null to every line made it a lot smoother LOL

rich adder
proper plank
#

i see

rich adder
#

the magic of it lets you spread code over frames instead of doing it at once

proper plank
#

i think what im tryna get at is that i just need something that can lazy load the grid in however much time it takes to load, bc all this stuff happens out of the view so it doesn't need to happen totally instantly

#

like idc how long it takes to load, i just want it to do it, not worrying about how many frames it takes

rich adder
#

yes you can use AsyncOperation to for example create a loading bar / screen

#

although if you need it to be it can be a multithread with jobs or just a plain Async/Awaitable func

#

Only thing Unity cares about is not calling most of its API out of the main thread

proper plank
#

so what would be the best course of action for my case

#

might be a bit of an issue with the api thing bc im creating a bunch of textures and meshes

rich adder
#

depends how you load/generate your grid

proper plank
#

im loading everything from a rom, and reconstructing the textures and meshes the first time a grid needs to load

rich adder
#

yeah but like for example? System.IO ? LoadResource methods etc.
some of those have async variants

#

can also docs async Awaitable VeryLongOperation(){ //do some work await Task.Delay(5000);//simluate a long running operation //done OnSomethingDone?.Invoke(whatever); }

proper plank
#

even with that it still hitches though

#

must be the fact that even though it's async or in a coroutine, the unity api calls just take too long

rich adder
#

if you're calling main thread stuff async will probably not change much

proper plank
#

guess i've just gotta go in and optimize my model creation process then

#

appreciate the help on helping me track this down

rich adder
#

okie. np . If you share more of the code we could take a look where it can be improved maybe

proper plank
#

yeah sure, one sec

#

it's still a PoC, so apologies if it's kinda bad lol

#

these are the only relevant files iirc, folderPath is empty in this case bc im not static-ly saving assets to the project, was originally for editor import use

rich adder
#

unless its the unpacking slowing down most of this shouldnt be so bad using it in a coroutine or even async with the OnInitialized static function launching all the prep

#

not sure where you got this from lol private async void Update()

proper plank
#

lol i forgot i left that there

rich adder
#

afaik the only entry async method unity has is Awake

proper plank
#

i mean you can just make it async and it still works

#

but obv it doesnt fix anything

rich adder
#

don't think Unity calls it as async though

#

just Awake afaik

sour fulcrum
#

whatever you cooking here looks sick and might be something i've def thought about messing around with doing but just a heads up that showing this might not necessarily be ideal aha 😅

proper plank
#

yeah you right

waxen adder
#

Let's say I have some UI elements on a canvas. They can process mouse events. However, I would like it so that if the elements are processing mouse events, anything "behind" the ui, like clickable objects in the gameplay world, won't also process mouse events. Any general ideas?

zenith cypress
teal viper
waxen adder
#

Ah ok, I'm doing something similar (but a little bit more barbaric compared to what you're doing). I'm basically firing off an event every time the UI has the pointer over it, and non-ui scripts can process that event. Leads to a lot more work compared to what you have though, so I'm gonna go change that XD

hidden marten
#

i tried to make my own wallrunning script on top of my player movement script. i want to stop the wallrun when i press space bar. but for some reason, sometimes when i press space bar the function is not called. can anyone take a look and help me out please?

eternal falconBOT
teal viper
hidden marten
teal viper
hidden marten
#

sorry i am a bit slow

teal viper
# hidden marten huh?

It would get executed on a frame when the time is >= 2. And there's no guarantee that frame would start exactly on the 2nd second.

hidden marten
teal viper
#

You can log during the invoke and inside the invoked method and compare the log timestamps.

hidden marten
teal viper
hidden marten
teal viper
#

"on method invoked"

hidden marten
teal viper
#

Debug log takes a string:
Debug.Log("text");

#

And you can also use string interpolation: $"text {variable}"

hidden marten
#

oh okay lemme try that out

hidden marten
#

this is the exitingwallrun bool btw

teal viper
hidden marten
teal viper
#

Especially considering they don't provide any details

#

It's also possible that you're calling the method somewhere else as well

hidden marten
hidden marten
willow shoal
#
    private Image _backgroundImage = null;
    private Image _controllerImage = null;

    [Header("Configuration")]
    [SerializeField] private bool _rightAnchorPoint = false;
    [SerializeField] private bool _topAnchorPoint = false;

    [Header("Generated Information")]
    [SerializeField] private Vector2 _virtualInput = Vector2.zero;

    [Header("Settings")]
    [SerializeField, Range(2f, 4f)] private float _controllerRange = 2.7f;


    public float HorizontalInput => _virtualInput.x;
    public float VerticalInput => _virtualInput.y;
    public Vector2 VirtualInput => _virtualInput;

    public void OnDrag(PointerEventData eventData)
    {
        if (RectTransformUtility.ScreenPointToLocalPointInRectangle(_backgroundImage.rectTransform,
            eventData.position, eventData.pressEventCamera, out Vector2 outLocalPoint))
        {
            CalculateVirtualInput(in outLocalPoint);
            UpdateControllerPosition();
        }
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        OnDrag(eventData);
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        _virtualInput = Vector2.zero;
        _controllerImage.rectTransform.anchoredPosition = Vector2.zero;
    }


    private void Awake()
    {
        _backgroundImage = GetComponent<Image>();
        _controllerImage = transform.GetChild(0).GetComponent<Image>();
    }

    void CalculateVirtualInput(in Vector2 localPoint)
    {
        Vector2 inputVector;
        Vector2 inputVectorClamped;

        inputVector.x = localPoint.x / _backgroundImage.rectTransform.sizeDelta.x;
        inputVector.y = localPoint.y / _backgroundImage.rectTransform.sizeDelta.y;
        inputVectorClamped.x = inputVector.x * 2 + 1 * (_rightAnchorPoint ? 1 : -1);
        inputVectorClamped.y = inputVector.y * 2 + 1 * (_topAnchorPoint ? 1 : -1);
        _virtualInput = inputVectorClamped.magnitude > 1.0f ? inputVectorClamped.normalized : inputVectorClamped;
    }
#
   void UpdateControllerPosition()
    {
        Vector2 controllerPosition;

        controllerPosition.x = _virtualInput.x * (_backgroundImage.rectTransform.sizeDelta.x / _controllerRange);
        controllerPosition.y = _virtualInput.y * (_backgroundImage.rectTransform.sizeDelta.y / _controllerRange);
        _controllerImage.rectTransform.anchoredPosition = controllerPosition;
    }

}

hi quick question... I want to change the camera joystick to turn the other way because when I turn left the camera turns right and I know that I just have to change some code

#

i need change one line of code for fix but i dont know which line of code change

gentle bone
#

when one side of the controller is "+1" and the other side is "-1" ... you probably just need to reverse them .. i think you will find your answer

willow shoal
#

i will check wait

#

nope :/ its not working

#

i found this script on github and i testing how it work

gentle bone
#

thats what i was thinking.. just copy & pasting without understanding doesnt help you in any way..

willow shoal
#

yeah

#

i will try my self fix it

#

up and down work well but left and right works the other way around

#

i find and learn how this script work

gentle bone
#

horizontal (x) is left and right.. vertical (y) is up and down.. maybe that helps

teal viper
teal viper
hidden marten
#

how do i change it so that the invoke method calls the function only once

teal viper
teal viper
hidden marten
teal viper
#

I'd recommend looking at some state machine tutorials.

hidden marten
scarlet aspen
#

why api scripting reference and package docks websites don't work?

teal viper
#

Someone spilled coffee on the servers

delicate portal
#

If I have a class which is subscribed to an event, then the scene changes, then gets back to the original scene, why does the listener not work? Should I unsubscribe then resubscribe?

hexed terrace
#

The instance of the component that did the subscribing was destroyed.
Loading the scene again is giving you a different instance.

sour fulcrum
#

if you unload a scene and load the same scene again those objects are not the same objects

#

they start out the same but they are not the same

delicate portal
#

Sure, so the solution is to unsubscribe on scene unloading and then resubscribe when it comes back

#

Right?

sour fulcrum
#

That would probably be ideal practice yeah, although it's worth noting that in practice in this case you shouldn't need to unsubscribe i don't think

#

Just mentioning in regards to logic still good to do

delicate portal
#

Yeah because the event is fired from an object which doesnt get destroyed on scene changes

#

Thats why I'm wondering why it doesn't work.
Currently I have a returning input which if you press a button, it holds "Back" function which disables the UI in front, and enables the previous one. If the scene changes, and we come back to the original one, this doesn't work, the returning feature doesn't do anything.

hexed terrace
#

always unsubscribe

eternal falconBOT
delicate portal
#

Or should I use OnEnable and OnDisable?

hexed terrace
#

start only runs once per instance

sharp abyss
#

Anybody knows how can I make my 3D active ragdolls arm follow my cursor like in game half sword. I dont have bones. I have 2 parted arms(upper and lower) with configurable joints.

verbal dome
sharp abyss
#

Yes the legs follow for walk but arms are free right now

verbal dome
#

Make the arms work and use some arm IK on the animator that it's replicating

#

Setting up proper active ragdolls is a massive pain though, just so you know.

hollow dawn
swift elbow
hollow dawn
swift elbow
# hollow dawn BRUH! what should I do then?
        float newHeight = isCrouching ? standingHeight : crouchHeight;

        capsule.height = newHeight;

        float heightDifference = previousHeight - newHeight;
        Vector3 positionAdjustment = new Vector3(0, heightDifference / 2f, 0);

        rb.MovePosition(rb.position - positionAdjustment);

        isCrouching = !isCrouching;```

no need to panic lol. i think something like this should work
#

dont forget to create an isCrouching bool

hollow dawn
swift elbow
vernal thorn
#

How too "spawn" a specific tile from a tilemap? context i have a json that specifies tiles for a world (2d) like this:

"tiles": [
        {
            "x": -5,
            "y": 0,
            "ID": "1"
        },
        {
            "x": -4,
            "y": 0,
            "ID": "2"
        },
        ...
    ]
}

and i want that for example ID 1 = grass ID 2 = dirt

rocky canyon
vernal thorn
#

oh thanks

rocky canyon
vernal thorn
#

ye i already did that

rocky canyon
#

so ID 2 would = Collection[2] etc..

#

then u could just do MyTiles[IDVariable];

vernal thorn
#

thank you for the information!

rocky canyon
#
tilemap.SetTile(position, tilesByID[tile.ID]);```
queen adder
#

hey could somebody help me understand how to debug the problem i'm facing? have a web development background and i started learning unity off a youtube tutorial today. it's a 2d top-down project and i have the animations working but my character's in the same spot. it's switching between the different walk sprites but it won't actually move around the screen if that makes sense

cosmic quail
queen adder
#

i do have vscode open but it doesn't help that this is my introduction to c#

#

i understand that though

rocky canyon
#

animation is just animation

#

u need to move the object with code

#

or use root motion <-- look that up

queen adder
#

i understand this but i don't know how to debug what's going on since this is my introduction to both unity and c#

rocky canyon
#

Debug.Log();

queen adder
#

i followed the tutorial but i must've missed something

rocky canyon
#

("The message u want to log");

queen adder
#

no error pops up or anything

rocky canyon
#

or.. (theVariable)

#

then ur code isnt running

#

or ur debug is somewhere it isnt getting reached

cosmic quail
queen adder
cosmic quail
rocky canyon
#

!code 👇 read

eternal falconBOT
queen adder
# cosmic quail show the script and show where you put it in the scene
using UnityEngine;
using UnityEngine.InputSystem;

public class playerMovement : MonoBehaviour
{

    [SerializeField] private float movespeed = 5f;
    private Rigidbody2D rb;
    private Vector2 moveInput;
    private Animator animator;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        rb.linearVelocity = moveInput * movespeed;
    }

    public void Move(InputAction.CallbackContext context)
    {
        animator.SetBool("isWalking", true);

        if (context.canceled) {
            animator.SetBool("isWalking", false);
            animator.SetFloat("LastInputX", moveInput.x);
            animator.SetFloat("LastInputY", moveInput.y);
        }

        moveInput = context.ReadValue<Vector2>();
        animator.SetFloat("InputX", moveInput.x);
        animator.SetFloat("InputY", moveInput.y);
    }

}
polar acorn
#

In update, log moveInput and see if it changes as you move your joystick around

#

Or keyboard buttons

vernal thorn
steady leaf
#

Me and my friend are trying to use Unity Version Control to collaborate. I invited him as a User to my project and he cannot create a new branch using the Unity DevOps Version Control app. Could someone help me how to give him proper permissions so he can create his own branch?

queen adder
#

it's logging the movement just fine afaik

polar acorn
# queen adder

Okay, so it should be setting the rigidbody velocity. Your scene looks pretty empty, are you sure it's not actually moving? If your camera is set to follow the player directly it might not even be possible to see movement

cold cove
cold cove
#

its not even detecting collisions why?

rich adder
#

how do you know

#

OnCollisionEnter/OnCollisionExit are not 2D physics methods

cold cove
#

oh

#

what would be a 2D equivilent

rich adder
#

take a wild guess lol

queen adder
#

would linking the video help?

cold cove
#

oh

rich adder
#

most of the 2d stuf you literally just append 2D to it

cold cove
#

oh ok thanks

viscid girder
#

Unity is asking me to choose a template, do i have to do this, nothing that i want to follow to start making my game says anything about templates?

rich adder
#

mainly the choice to consider is URP vs HDRP

#

or BiRP (although this is being phased out)

viscid girder
#

ok ill research the differences

#

thanks 🙂

green copper
#

if I have a large 2d environment, no player character just the camera as an overseer, how can I get a smooth movement between rooms?

I have camera anchors for each room, and I can make it move between them, but I'd like to be able to make the camera movement smooth and crisp, where it quickly swooshes from one point to the next without stopping or starting instantly but also not just sliding_stone_block.mp3

zinc charm
#

I have a resource bar that's continiously draining, multiplied by deltaTime. I also have an event that broadcasts the resource amount in Update(). I initially thought updating the event would be slower performance wise so added a timer to update the event every second, is this right?
I tried to use the profiler but I am not sure which metrics I want to look at for this.

rich adder
zinc charm
#

I think it is just a pointer updated in the system but I am not sure if there are other performance handicaps

rich adder
#

yeah you should fine

shadow kettle
#

in the programming pathway course, in the plane programming part, the plane starts rotating on its own when it touches the wall, how do i fix that?

rich adder
shadow kettle
white lagoon
#

how do i make a variable name use another variable's value to make that name

#

as in I want to create a variable called "Level (variable)"

#

or is that not possible

naive pawn
#

it isn't possible, those happen at different types

cosmic quail
#

why do you need this?

naive pawn
#

why do you want to do so?

white lagoon
#

i want to create a variable called level"variable dependent on stage"completed

naive pawn
#

why do you want that variable though?

white lagoon
#

so i can check if it's true to check if the player unlocked a stage

#

another question, is a global variable persistent between scenes

runic lance
white lagoon
#

static public

runic lance
#

most likely what you want is just a collection storing the ids of the completed stages

naive pawn
runic lance
naive pawn
naive pawn
white lagoon
#

yes, each with a different number depending on the current stage number

naive pawn
#

if you ever end up with numbered variables, you most likely want some kind of collection instead

#

are your levels sequential?

white lagoon
#

yes they are

naive pawn
#

so why not just have a single variable that tracks how many levels have been completed

rare elm
#

trying to learn unity lingo. when people talk about a character controller, is that the interface with the joystick, the behavioral control for the rig, both, or more

frosty hound
#

It's the entirety of everything involved with making a gameplay character.

rare elm
#

even the art and network?

frosty hound
#

If it's involved with making the character, yes

rare elm
#

alright. thanks

naive pawn
hot palm
#

Quick question, can I have default references of arrays? As they are of non-changeable length, I thought it would be possible, but they aren't displayed in the inspector

rich adder
hot palm
rich adder
#

you should be able to since they are assets and not scene objects

hot palm
#

Ah I guess I just made them public but didnt serialize the field

rich adder
#

public is already serialized

hot palm
#

Then it didnt work

rich adder
#

you made them field not property right?

hot palm
#

let me try your version

rich adder
#

yea looks fine

hot palm
#

Dont appear

#

Whereas mixer does appear

#

Quick check, I just did AudioClip instead of AudioClip[] and I did see the AudioClip there

rich adder
#

oh thats strange.. let me try it on my end. maybe its true which would be odd..

#

I think maybe because Unity Initializes an array when it is attached as a component

hot palm
#

Hmm let me try list

rich adder
#

I wonder if it works if you added new()

hot palm
#

Let me try

rich adder
#

[SerializeField] private AudioClip[] clips = new()

hot palm
#

Ah he doesnt like that

#

Dont see the new() List either

#

Lets see what happens with this

private AudioClip[] clips = new AudioClip[1];
rich adder
#

ya sorry you need fixed size for array

hot palm
#

ah doesnt work

#

Still wont appear

#

Google wont tell me either

rich adder
#

thats balls

hot palm
#

Glitch in the matrix

rich adder
#

def something to do with the Editor drawing

hot palm
#

Using Unity 6000.0.36f1

#

Ah so it should work but for some godforsaken reason it wont? :D

#

let me restart editor

rich adder
#

I just tried it

#

its not that

hot palm
#

Ah okay

rich adder
#

i think for arrays unity does something different so it needs an instance

#

you can make a simple workaround though if you want to still do that

#

put your array inside a ScriptableObject then make a field for that, it should work

noble needle
#

hey guys can someone help

hot palm
#

Hmm alright. To fight the root of the problem: How would I have a collection of AudioClips, and in my script I access them

// Play sound
AudioClip newShootSound;
do
{
    newShootSound = EnemySoundManag.Instance.ShootSounds[UnityEngine.Random.Range(0, EnemySoundManag.Instance.ShootSounds.Length)];
} while (newShootSound == shootSound);
shootSound = newShootSound;

AudioManag.Instance.PlayAnySoundFromList(VolumeType.SFX, clip: newShootSound, volume: 0.2f);
#

It's annoying to have to have a Singleton thats holding all the audio data but hey, I could (un)load the data individually per level then I guess

noble needle
#

I have this slider in the scene but when I switch to the game it doesn't show up 😦

rich adder
hot palm
rich adder
rich adder
#

some objects have their own sound component on them

hot palm
#

Oh yeah, for music I do that (with a custom looper class but still)

#

Hm I guess I'll just do it like this. Not as manageable as I had planned but it's still alright I guess, will keep a prefab and add it to each scene ig

rich adder
#

the reason I like not storing on the enemy per se, is if you have an event thats all you need to "listen" to

hot palm
#

Yeah

rich adder
#

like if enemy Jumps, why not just access that from a dictionary.

the enemy only cares about OnJumped?.Invoke()
the rest reacts to it

hot palm
#

Could make "blue enemy" inherit from a "enemy" class with that event action but this works for me

hollow dawn
#

There's a bug in unity 6 that I completely forgot about

#

Where would I report it?

rich adder
#

something magical happens if you google that same exact thought

hollow dawn
rich adder
#

only a sprinkle?

hollow dawn
rich adder
#

I'm not lol I've seen it all here almost, some people legitimately forget there is a search engine now days

hollow dawn
#

If you wanted to know what the bug was the listen button doesn't work because in one of the scripts they spelt Search wrong it says > Seach instead

rich adder
#

that would be pretty funny if they did

hollow dawn
#

It happened to me I check and it was right there "Seach"

#

put a r in there an it was fixed

naive pawn
#

hasn't this been reported already

hollow dawn
naive pawn
hot palm
hollow dawn
naive pawn
#

even if it hasn't been fixed, if it's already been reported, you reporting it again will just be noise

#

go find the original report and boost it

hot palm
rich adder
#

if its already in the tracker yes you should vote it up

hot palm
rich adder
#

although fixes like this aren't pushed right away

hot palm
#

Coroutines waiting for next frame with yield return null is Time.timescale independant, right?

hollow dawn
slender nymph
#

also note that it is not the editor version that matters, but rather the input system package version

rich adder
#

the unity version wont matter if its Input System it probably gets updated in the package

#

jinx

hot palm
#

lmao

#

Ur both right, I feel double stupid now :')

slender nymph
hot palm
rich adder
#

WaitForEndOfFrame(); has tiny extra allocation but its the same thing no?

slender nymph
hot palm
#

So the default syntax for waiting a frame is to yield return null?

naive pawn
hot palm
green copper
#

If I'm trying to create a main game manager node to hold a bunch of random important information related to overall stats and supplies and such

Would it be better practice to

-shove everything into one script on one object

-multiple scripts on one object

-object has children with categories, like
main > gunnery > scriptThatHandles Gun > artilleryGunAzimuth
main > supply > scriptThatHandlesStorage > medkitsInStorage

hot palm
hot palm
# naive pawn

Basically step away from visual studio and build a readable graph just like this

naive pawn
#

draw.io is a great for that, and it's free

#

powerpoint is also viable

#

don't need anything fancy

hot palm
#

paint.net is my personal favorite for simple stuff. It's free (on the official page, not the microsoft version) and has a lot of cool tools which paint or paint3D are missing out

green copper
#

I'll give that a shot, didn't think to pre-map my logic out like that

#

did something similar for my screen layout WIP

noble needle
#

how can I make a slider slidable with the mouse?

hot palm
rich adder
green copper
#

yeah, that makes sense
I've done some pretty complex things in a few languages for school and for my first job, but this is my first time being the one MAKING the design specs instead of just following them

noble needle
rich adder
#

also this isnt' a code question

noble needle
#

oh mb

noble needle
keen cargo
#

If it doesn't move then something is either keeping it that value, or you might have an ui element blocking it

#

Like an invisible panel or something

rich adder
# noble needle yes

inspect the Event System in playmode when you click something, see what it is

noble needle
#

ohhhh

#

these 2 are different things?

#

also why is my camera so zoomed in

rich adder
naive pawn
rich adder
cold cove
slender nymph
#

define "crashing" here, because there's nothing in this code that would generally cause anything to "crash"

cold cove
#

the entire editor just stops working

#

Idk why

slender nymph
#

then it's some other code

cold cove
#

when I try shoting

#

It works when I dont do this it is this

slender nymph
#

when I try shoting
so then maybe show the code for that

polar acorn
#

Nothing here involves shooting

slender nymph
#

also it is against server rules to not disclose AI generated code 😉

cold cove
#

this is the code

#

spawning

#

its not Ai I promise

#

I spent 30 minutes trying to get it work

#

it spawns the bullet and gives it velocity or am I stupid?

polar acorn
cold cove
#

GameObject newObject=Instantiate(objectToSpawn, transform.position, Quaternion.identity);

bright osprey
#

think you may have pasted the wrong class mate

zenith cypress
#

Yep

polar acorn
cold cove
#

oh I might have posted the wrong code my bad

slender nymph
#

there it is, you have an infinite loop

polar acorn
cold cove
#

how if they are slowly coming closer

polar acorn
cold cove
#

oh I am stupid

#

wait I am gona try dixing it

naive pawn
#

you're using deltaTime, so it seems like you want it to move over several frames

polar acorn
#

Putting "MoveTowards" in a while loop also doesn't make sense. If you want the object to go towards the destination in a single frame, just set the position

naive pawn
#

the while loop will make it happen in a single frame

polar acorn
#

It'll do the same thing

cold cove
#

not a single frame

polar acorn
#

It's in update

cold cove
#

do I need a seprate function?

polar acorn
#

The definition of a frame is how long it takes for every objects update functions to finish

#

Everything done in update will, by definition, take 1 frame to do

naive pawn
# cold cove not a single frame

the while makes it do MoveTowards multiple times
and it's within a single Update call, so it's happening in a single frame

#

you might want an if instead?

cold cove
#

Do I need a IEnumerator function if I wan it to slowly be moving twoards the location

polar acorn
#

Or do it over multiple updates with a timer variable

#

Either one works

naive pawn
#

you only need to change the while to if

cold cove
#

Its not moving at all

#

it just spawns and thath is it

#

oh I got too litle range I g

drowsy field
#

ive got something i wanna correct with the unity input plugin when it comes to inputs that trigger every frame
because my mouse left click function only triggers once when the mouse is clicked, instead of me wanting it to trigger every frame

#

(me trying to make an automatic weapon but it ends up just firing once)

cold cove
#

still not moving

#

why????

polar acorn
cold cove
#

changed while to if

drowsy field
polar acorn
drowsy field
cold cove
#

I got most of the things out of the press left click it says this Assets\shoot.cs(21,54): error CS0103: The name 'newObject' does not exist in the current context

#

I get why but dont know what to do about it

polar acorn
# drowsy field

So that's only calling it on started, which is when it goes from 0 to a non-zero value, and won't start again until it returns to 0

drowsy field
polar acorn
drowsy field
#

i set it to started to see if it would fix (my movement is called this way, manages to work fine, but the mouse click just doesnt wanna happen every frame)

#

gonna try to see if putting it into the update function will fix something

drowsy field
#

now it's working fine

acoustic sequoia
#

hey everyone, what is the best practice to make a visable "visual only" grid for players to refference. 2d games usually have a visual grid that looks like very thin string-like lines.

how should i approach this? I was thinking about using the line tool but it seems like overkill. any suggestions?

sour fulcrum
acoustic sequoia
cold cove
#

I am getting a bunch of erors for unknown reasons

sour fulcrum
acoustic sequoia
rich adder
#

linerenderer

cold cove
#

I have to where my bullets destroy how can I make the original one not do this I kinda need it its a refrence for everything else spawning

#

if u need further explanation I can send code

rich adder
#

which original

cold cove
#

how do I do thath

rich adder
#

isnt clear what you're asking here

cold cove
#

I will send you the code for the bullets

rich adder
cold cove
#

well how can I make the original bullet thath my weapon is refrencing not disapear

#

is this posible

cold cove
#

yes

#

this is the weapon code

rich adder
#

its just cloning it

cold cove
#

yeah

#

and it gets destroyed by the bullet code

rich adder
#

you should be referencing a prefab

#

not a scene object

cold cove
#

can you explain it or should I gogle it

#

first time I hear of a prefab

rich adder
#

drag the bullet in the Project folder, now its a prefab. Remove it from the scene and drag n drop THE BLUE in project folder to the Gameobject field on Weapon

cold cove
#

ok I get it

rich adder
cold cove
#

thanks

#

its agin not working : (

rich adder
cold cove
#

its getting destroyed

rich adder
cold cove
#

whivh one

rich adder
#

did you read this part

cold cove
#

didnt know I was suposed to my bad

#

My tracking isnt working

#

I am gona cry

#

the bulets arent going the corect way

#

for

#

some reason

#

when I am on one platform its normal on the next one its glitching

rich adder
#

idk but this doesnt seem like should be in the bullet in update
mousePosition=Camera.main.ScreenToWorldPoint(Input.mousePosition);

#

as it always changes..

cold cove
#

I dont know where to put it

#

it dosent work when in start

rich adder
#

just pass the direction directly from the shoot

cold cove
#

how?

rich adder
#

var spawnedBullet = Instantiate(objectToSpawn, transform.position, Quaternion.identity);
spawnedBullet .GetComponent<bulet>().Shoot(passDirectionHere)

#

make a new method for Shoot

#

the shoot script should be the one tracking the mouse

cold cove
#

what is this I am getting mind blown

rich adder
#

this all basic c# stuff mentioned earlier you should probably do.

#

also you probably don't want to directly move the transform if you plan on using collisions

cold cove
#

future me problem

#

wait but why am I calling the shoot method agin

rich adder
cold cove
#

oh okay

eternal needle
mental rock
#

Hi, I'm having an issue trying to make a following camera on my 2D game look decent. Currently, it follows the player successfully; it even has a little smoothing to it so its not locked perfectly onto the player while in motion. Unfortunately, while in motion, the player sprite looks horrendous. It appears to jitter in place.

The sprite I'm using is only 12x32 pixels, which I assume is one of (if not the) reason why this issue is happening. If it is, what should I do? Should I actually make the sprite much larger and then scale it down in the editor?

cold cove
#

why am I having this error
Assets\Scripte\shoot.cs(16,39): error CS0246: The type or namespace name 'bullet' could not be found (are you missing a using directive or an assembly reference?)

naive pawn
#

so it's pixelart?

naive pawn
mental rock
naive pawn
cold cove
naive pawn
#

it's an object?

#

you tried to use it as a type

#

it doesn't exist as a type

cold cove
#

I am confused how can I corect this?

mental rock
#

(also I'm not sure what you mean by the pixelart asset stuff)

#

Is it an FAQ I overlooked

naive pawn
hexed nymph
#

Yoooo, how do I pause only some elements of the game?

#

public void Pausar()
{
if (GameObject.FindGameObjectsWithTag("PauseThings"))
{
Time.timeScale = 1f;
}
else
{
Time.timeScale = 0f;
}
IntroAnim();
}

naive pawn
cold cove
#

I wana acses the sript of the bullet I spawned

polar acorn
cold cove
#

the script is also called bulet

naive pawn
hexed nymph
naive pawn
mental rock
polar acorn
cold cove
naive pawn
# hexed nymph Yoooo, how do I pause only some elements of the game?

either:

  • make your own system to handle pausing, where you set a variable and the stuff that should be paused checks for that to stop running
  • make the stuff that shouldn't be paused, use unscaled time instead. but that'll make it not respond to anything else that affects timescale as well
cold cove
#

this is the code
if (Input.GetMouseButtonDown(0))
{
Vector2 mousePosition=Camera.main.ScreenToWorldPoint(Input.mousePosition);
var spawnedBullet = Instantiate(objectToSpawn, transform.position, Quaternion.identity);
spawnedBullet .GetComponent<bullet>().bulet(mousePosition);
}

polar acorn
naive pawn
#

your player is 16x32, so maybe ppu would be 16 or 32 depending on if your player should be 1 or 2 units tall

cold cove
#

its a prefab

#

not a class

naive pawn
#

what component are you trying to get there

polar acorn
# cold cove nope

Then why are you trying to get a script named bullet if you have none

cold cove
#

I have a script bulet inside the prefab bullet

naive pawn
naive pawn
# cold cove

ok so it's named bulet
but you're trying to get a script named bullet

#

see the issue here?

rich adder
#

even my example had the wrong spelling but correct class

polar acorn
# cold cove

Okay but what does that matter? You're trying to get a component named bullet

naive pawn
#

anyways since you want to access that component, you should use that component as the type for your prefab instead of GameObject or Transform or whatever you have it as now
then you can get the component directly back from Instantiate instead of having to go through GetComponent

cold cove
#

So I swap the first to bulet and the second I gota make a oublic vector?

naive pawn
#

what first and what second here?

#

we've been talking about a single thing

cold cove
#

<bulet>().Mouseposition(The mouse position vector I found)

cold cove
naive pawn
#

does your script have that function?

cold cove
#

no it dosent I gota change it

mental rock
# naive pawn where are you updating your camera position?

It's in its own script attached to the camera, it was originally in the LateUpdate() method which had its own horrendous-looking jitter to it, so I changed it to FixedUpdate(). While that does look much better, its clear that there is some issue with the pixels of the sprite when the player moves.

cold cove
#

can I just move this one wariable from here to bullets code

naive pawn
#

if it's in FixedUpdate it might not be moving every frame

mental rock
#

Yeah it was but it looked even worse than FixedUpdate()

#

it caused the player sprite to jitter back and forth and blur while doing so

naive pawn
rich adder
#

no need to track mouse in every bullet spawned, that was the point of that btw

cold cove
#

I am stupid for programing

#

lol

rich adder
#

you're just trying to Run before learning how to crawl

cold cove
#

It gives me an eror

#

: (

mental rock
cold cove
#

nvm I am just confused asf

mental rock
#

Without the smoothing effect it looks completely fine but it would be a big shame to have to drop it

rich adder
cold cove
#

what is this

#

it isnt working for some reason

rich adder
#

we don't have eyes on your pc

cold cove
#

I know

#

why this aint working

rich adder
#

also why is your IDE not configured

#

I thought you did that

cold cove
#

why do I have one

#

I did its omething else

naive pawn
#

because you made a mistake

naive pawn
rich adder
naive pawn
#

there'd be a lot more green if it were configured

rich adder
#

and underlined red that Shoot() function

#

not even using the same capitlization...lord

#

and why does the one in bulet return an int

#

this just goes from worse to horrible the more i look

cold cove
#

I know

rich adder
#

a while loop 😬

cold cove
#

I am stupid asf I tried it a bunch of stuff

#

this last stuff is just despration

rich adder
#

yeah this isn't a guessing thing

#

you have to be exact with this..this like exact math/science you're dealing with

#

throwing random stuff at the wall won't work

cold cove
#

swap the while for an if and make it a void function

#

better?

rich adder
#

thats like 2% of the bigger problem

#

if is wrong, why put an if there?

#

if all you're doing is tracking how far it went from your shoot pos then track that in update

#

mousePosition/targetPos should be a field that gets its value from Shoot Method

cold cove
#

oh so method is just to get position

rich adder
#

the method is just to get value from another script

#

so you dont have 200 bullets track the mouse

cold cove
#

oh okay so I figured it out thanks

rich adder
#

Vector2.MoveTowards ignores whats between just fyi

#

your bullet would phase through obstacles/walls

cold cove
#

I will do on colison later

rich adder
#

OnCollision doesn't help

cold cove
#

just one question its saying something something protection level

rich adder
#

transform literally teleports, its not good collision

cold cove
#

on collision2D destroy

rich adder
#

screenshot the error otherwise we can't help

cold cove
#

just move tworwards?

rich adder
#

you made shoot() private

#

of course it cant be accessed from other scripts

#

this is partially why a configured IDE is important so you can catch these before hitting save and going into unity..

cold cove
#

I didnt

#

thath is the thing

#

Idk I gota sleep

rich adder
frail heath
#

Tried to make a jumping and walking animation, Walking works but I cant jump anymore: (

#

this is the code

rich adder
#

also Animator might be taking control of the transform? idk

wintry quarry
#

which doesn't seem right to me

frail heath
#

I see what should I change

wintry quarry
#

especially since then you're doing isGrounded = false inside that

wintry quarry
frail heath
#

when im grounded

wintry quarry
#

so make the code reflect that

rich adder
#

! means NOT remember

frail heath
#

oh righttt

rich adder
#

you probably just wanted to keep it for animator.SetBool("isJumping", !isGrounded);

#

but not when on ground to jump

wintry quarry
#

Secondarily:

    private void OnTriggerEnter2D(Collider2D collision)
    {
        isGrounded = true;```
This isn't the most robust grounded check, you may run into problems in the future with this
rich adder
#

look into Raycast and alike

#

maybe boxcast so its wider.. ? depends on you want the shape to be ideally to match bottom half of your collider

frail heath
#

I see thank you very much! this is my first platformer trying top learn as much as possible

grand snow
#

"MonoBehaviour" is what you want to make

viscid girder
#

oh just fingured it out 😭

#

thanks though :)))

grand snow
#

👍

livid arch
#

does this make sense? im coming from python so im not sure if this is how it works, it says == isnt valid

 if (GameObject.GetComponent.Collider.OnCollisionEnter(Collision)) == True;
            {
                 playerBody_Ragdoll.AddForce(Vector3.up * playerJumpForce, ForceMode.Impulse);
            }```
rich adder
#

also you should configure your IDE

#

saw your ide was def not configured

livid arch
#

ide?

rich adder
#

yeah your code editor

#

VSCode

livid arch
#

i mean i kinda just installed it and got it working lol

rich adder
#

its not working correctly

#

it should've underlined all that

livid arch
#

i think theres a unity debugger extension

rich adder
#

it would not show the entire path

#

colors are off

#

and at the bottom it would say Project: Assembly-CSharp

acoustic sequoia
#

can someone help me this something i never thought would be so difficult lol
I'm trying to draw a rectangle on a grid with mouse dragging.

It's working.. but it's inverted when im dragging in a negative direction.
so i want to flip the start and end positions of the mouse drag if it's moving in a negitive direction.. how to do this seems really difficulkt.

rich adder
#

which i bet doesnt

wintry quarry
rich adder
livid arch
wintry quarry
#

!ide

eternal falconBOT
livid arch
rich adder
livid arch
#

ah ok

livid arch
rich adder
#

as long as you didnt install them using some type of self-contained install such as Flatpak

livid arch
rich adder
#

its always best to use apt get when possible or .deb (if you're ubuntu,debain mint etc.)

#

also one of the important steps is having the .NET SDK and the Unity Package Visual Studio Editor package

verbal dome
#

For example cs Vector2 min = new Vector2(Mathf.Min(start.x, end.x), Mathf.Min(start.y, end.y)); Vector2 max = new Vector2(Mathf.Max(start.x, end.x), Mathf.Max(start.y, end.y);

#

Oh I just learned that Vector2.Min/Max exists too, so you can also do: cs Vector2 min = Vector2.Min(start, end); Vector2 max = Vector2.Max(start, end);

livid arch
wintry quarry
verbal dome
#

Just remove that semicolon

livid arch
#

it changes the error

verbal dome
#

You put it inside another method, don't do that

#
void Method()
{
  void LocalMethod()
  {
    
  }
}```
wintry quarry
livid arch
verbal dome
#

Unity won't find it that way

livid arch
#

i move a subset of the movement script inside the movement

#

ah,

wintry quarry
#

it needs to be its own function

livid arch
wintry quarry
#

it needs to go inside the class, not in any other functions

#
// You put it here. Bad.
void FunctionWrong() {

}

class MyClass {
  void Function1() {

  }

  void Function2() {

  }
}```
livid arch
#

it was this extra bracket at the top

wintry quarry
#

yes you have to be careful with your brackets, they are what define the boundaries of the various code elements (classes, methods/functions, if statements, etc)

livid arch
#

ya

#

im guessing it cant find my playerRagdoll_body? (using screenshots cause i feel like knowing the code lines are important)

wintry quarry
#

playerBody_Ragdoll is null, yes. You need to make sure you've assigned it a value before you use it.

#

It's not about "it can't find it". It doesn't try to find anything automatically. You have to give your reference variables a value either by assigning them in code or in the inspector.

livid arch
wintry quarry
#

Like I said

#

assign it in the inspector

#

or in your code to whatever type of value it is

#

"an object" is kinda meaningless. Everything in C# is an object

#

do you mean GameObject?

#

I think it's a Rigidbody most likely based on the context here, not a GameObject

#

The most straightforward way to assign values to your references in Unity is through the inspector. I would stick with that for now.

livid arch
#

ohhh, yea its a rigidbody

#

well, its a rig i wanna put on a rigidbody

#

rigid body is more of the collision

#

i forget i cant "attach" scripts like in godot they need to reference the object specifically i think

#

oh i set it to private? maybe if i make it public

wintry quarry
wintry quarry
#

perfect

livid arch
#

can i export a procedural texture from blender to unity?

teal viper
livid arch
teal viper
#

And you can't export shaders between blender and unity(or any other programs really).

lilac fractal
#

I downloaded an asset pack that has both tiles and objects. The tiles were fine and I managed to put them into a TileMap, but the objects are all different sizes

#

Is there an easy way to get these into unique sprites?

#

And then once I have them in unique sprites, what's the way to use them as such? Do I just layer them on top?

lilac fractal
#

ah fair point

#

yeah that was my first attempt but since they're different sizes it slices them up poorly

rich adder
#

use autoslice and it tries its best then you need readjusting, the link I sent addresses that

bronze thunder
#

I'm not sure if this is the right place to ask, but I'm feeling real stupid. I'm using unity 6 with Visual Studio 2022 on Windows, and it seems like when I edit a script, it updates in the display window in unity, but I have to close the editor then launch it again to get it to update the behavior when I press play. is this intended? Or is there something im likely doing wrong?

verbal dome
#

You need to turn it on or manually refresh withi Ctrl + R

bronze thunder
thorn holly
#

So I made a pretty basic chunk loading system that feels unnecessary to run on the main thread…I check if the player moves to a different chunk in update, and if they did, calls a method to delete far away chunks and make new ones. Should I make chunk drawing method async/await? run on a different thread? What’s the best move here

teal viper
#

Alternatively make it async on the main thread.

thorn holly