#💻┃code-beginner

1 messages · Page 249 of 1

swift crag
#

in 3D, you have:

  • normals: the direction different parts of the object's surface is facing
  • smoothness: how clearly the object reflects light
  • metallicity: how much the object's color tints its reflection
#

and there's no reason you can't add more maps that define more qualities of the material

fringe plover
#

I want to kill myself after coding this (not a question)

woven crater
#

so like a texture pass onto a plain color sketch?

rare basin
woven crater
#

@fringe plover 🤝

fringe plover
#

Holy sh-

gaunt ice
#

call back hell

verbal dome
buoyant knot
fringe plover
#

HOW

buoyant knot
#

write methods in local scope to reduce nesting

buoyant rune
#

where did all my animations go, they still play in game but i dont see the state machines

buoyant knot
#

also you can check if the opposite, then log error, and return

#

if (val == null){
do X;
if (next…)
..
}else do Y;

Is the same as;
if (val != null) {
doY and return;}
do X;
if (…)

fringe plover
#

okay ill try

buoyant knot
#

then you won’t have 69 layers of nested ifs

tall delta
# fringe plover HOW
public async Task<string> UsePromo(string code) {

    var isLogged = await IsLogged();
    if (isLogged == false) return "you need to login";

    var isValid = await IsPromValid(code);
    if (isValid == false) return "code is invalid";

    var isValid = await IsPromUsed(code);
    if (isValid == false) return "code has been used";

    return "code is valid";
}```

something like this would be my first idea
fringe plover
verbal dome
buoyant rune
verbal dome
sullen rock
#

https://gdl.space/tezupoxejo.cs hello, I have this piece of code that takes a set of instructions (along with timers) and outputs an 8-byte array that encodes that data for further transfer (debug.logging atm)

it seems to work, but Im looking to optimize it a bit, would love some advice with that!

verbal dome
#

Also have some patience

buoyant knot
#

yeah, just flip your if statements so you can return as fast as possible

buoyant rune
#

still does anyone know?

buoyant rune
buoyant knot
fringe plover
buoyant knot
#

he literally breaks up something that looks exactly like your code

cosmic dagger
buoyant knot
#

yep. 69 is just a standard, arbitrary number

#

when you only ever need a max depth of 1 for this code

fringe plover
#

okay...

tall delta
# fringe plover okay...

I'd say that the readability / maintainability of the code you posted is of secondary concern.
the main issue I see is that you are doing what I assume is a web request in a synchronous manner, this will then "freeze" you game while the code is running / checking the code.
using async/await model or a coroutine should be the first point up for a refactor imo.

fringe plover
buoyant knot
#

because unmaintainable/illegible code is the fastest way to get something that works, breaks later, and now you have a bunch of code that depends on code that you cannot fix

fringe plover
#

i wanted to use return instead of Action things, but i used Action cuz of weirdness of API that i use...
Maybe there was more ways to do it but tbh.. i dont know how...

gaunt ice
#

write a named function

fringe plover
buoyant knot
#

it can even be local scope, if you need

#
   for (int i = 0; i < 5; i++) {
       Increment();
   }
   return x;
   void Increment() { x++; }
}```
#

here, Increment can only be used within the scope of Count(, but it is at least named

fringe plover
#

oh...

gaunt ice
#

now you have an api as following

public class TheObject{
  TryThing1(params, Action onSuccess);
  TryThing2(params, Action onSuccess);
  TryThing3(params, Action onSuccess);
}
```then you can write
```cs
private TheObject theObject;
public Try(){
  theObject.TryThing1(params,OnSuccess1);
}
public OnSuccess1(params){
  theObject.TryThing2(params,OnSuccess2);
}
public OnSuccess2(params){
  theObject.TryThing3(params,OnSuccess3);
}
#

btw some api use singleton, you dont need the field in this case

fringe plover
#

ill try ig.. i still need to recode it... so, thanks for advice, i need to learn how to use these...

buoyant knot
#

locally scoped functions just let you to define a named function, without actually adding a member to the class

#

tina is referring to just writing actual member functions

#

the never nester video should give you ideas of how to straighten out nested code

gilded verge
#

i want to have an enemy follow the player. why is having agent.setDestination(player.position) in update gives the navmeshAgent a seizure and doesnt move?

gilded verge
fringe plover
#

make sure its placed on NavMesh

gilded verge
fringe plover
#

do you mean it does move top player start pos, but doesnt follow player?

fringe plover
#

make sure its on Update + player may be unreachable

#

im not sure ho it works, tried NM only once

gilded verge
gilded verge
fringe plover
#

what exactly is player.position??? isnt it supposed to be player.transform.position? or you have it recorded in script?

#

maybe this value doesnt change

gilded verge
#

here this is a video

buoyant knot
#

in general, I don’t think you want to move a transform when something else is moving the transform

gilded verge
buoyant knot
#

like you don’t want to move a transform when the transform is being controlled by a rigidbody

#

idk if navmesh is the same, but maybe it is

gilded verge
wintry quarry
#

they're not moving the Transform

swift crag
#

Is Application.quitting guaranteed to fire before Unity starts destroying objects?

#

I have entities that need to do some cleanup when playing the game in the editor, since I have Domain Reload disabled

#

I want them to be able to do this before random stuff is being destroyed

hot wave
#

thank you nitku, I think I understand how it works now UnityChanOkay it was confusing but I know how to make flow properly now

#

also I ate KFC earlier UnityChanCelebrate I am happy

swift crag
#

oh, the plot is thickening in interesting ways

#

i was assuming that destroying a game object destroyed its components and children in some kind of order

#

looks like it's more random

#

ah, that's not even what's happening here, though

#

I have an Entity that references a Brain. I need to tell that brain to disengage so that it unsubscribes from InputAction events. The brain is not parented to the entity

#

I tried having the entity respond to OnApplicationQuit by destroying itself, and then disengaging the brain in OnDestroy

#

But destruction doesn't happen until the end of the frame normally, so this doesn't do anything immediately

#

then Unity starts destroying everything in the scene, and it winds up destroying the brain first

#

(and the entity skips trying to disengage the brain, because it thinks it has no brain at all)

#

ugh

#

I guess I'll have the brain disengage itself if it gets destroyed

hot wave
#

this sounds so scary without context UnityChanDown

#

I havent tried brain thingy yet, but hope you find a solution UnityChanSalute

candid tree
#

bro what should i do with my code, so i want to make my game to pick up all object in my game

using System.Collections;
using UnityEngine;

public class CarryObject : MonoBehaviour
{

    public GameObject pickAbleObj;
    ArrayList pickableObj = new ArrayList();
    public Transform handPlayer;

    public float range = 2f;

    public GameObject pickUpButton;
    public GameObject dropButton;

    private void Update()
    {
        CheckForPickableObject();
    }

    public void CheckForPickableObject()
    {
        RaycastHit hit;
        if (Physics.Raycast(transform.position, transform.forward, out hit, range))
        {
            // Memastikan bahwa objek yang terkena adalah objek yang bisa diambil
            if (hit.collider.gameObject == pickAbleObj)
            {
                pickUpButton.SetActive(true);
            }
            else
            {
                pickUpButton.SetActive(false);
            }
        }
        else
        {
            pickUpButton.SetActive(false);
        }
    }

    public void PickUpObject()
    {
        if (pickAbleObj != null)
        {
            pickAbleObj.transform.position = handPlayer.position;
            pickAbleObj.transform.SetParent(handPlayer);
            pickUpButton.SetActive(false);
            dropButton.SetActive(true);
        }
    }

    public void DropObject()
    {
        // Memastikan ada objek yang dipegang sebelum mencoba melepaskannya
        if (handPlayer.childCount > 0)
        {
            pickAbleObj.transform.SetParent(null);
            dropButton.SetActive(false);
        }
    }
}

frosty hound
#

Classic, doesn't actually read beyond the first sentence. If you're not going to, why even bother asking questions.

dim brook
#

im loading in a sprite with this code

#

and the image is alerady set to transparent

#

but when the game loads it in it's set as a white square at first

static bay
#

Do you know what the 4th argument does?

dim brook
#

transparency?

static bay
#

yep

#

alpha

dim brook
#

but if the original photo is already transparent

#

that wouldnt do anything right

static bay
dim brook
#

like it's just a blank png image

static bay
#

By default a UI Image is a white square. If you set the color's alpha to be 0, then ya it'll be invisible. You seem to be setting alpha to 1 at some point before the Pokemon comes out.

dim brook
#

odd

#

ill keep looking ig

wintry quarry
dim brook
#

oh yea i just changed it and it makes no difference LMAO

tender stag
#

this unfreezes my rotation cs rb.constraints = RigidbodyConstraints.FreezePositionY;

#

how can i just freeze the y position while leaving the other stuff alone?

wintry quarry
tender stag
#

alright now how can i unfreeze the y position?

wintry quarry
#

or if you want to literally "leave everything else alone:
rb.constraints = rb.constraints | RigidbodyConstraints.FreezePositionY;

wintry quarry
tender stag
#

alright thank you so much

buoyant rune
#

not sure why death animation for boss doesnt play, i use th same enemy health script for both enemy and boss, the animation for death does play for enemy but doesnt for boss

wintry quarry
stone pebble
#

Hi! I am in a bit of a major bit of confusion right now, so I am asking for help in this forum.

I am doing a study using unity, so my game is basically a big questionaire. I plan to collect information into a class and simply send it as a .json string to my server. Problem is the communication with the class. This class has to be non-static, sure, but the object of the user should be available to multiple scripts and receive information from multiple additively loaded scenes. I am at a loss on how to organise such a thing, whether i should use events or anything else to facilitate communication between multiple additively loadedd scenes. If anybody of you did something similar, please let me know of your solution!

P.S: I tried simplifying the issue, but it would be very unwelcome to move to a single scene, as I am loading different parts of study logic as different scenes (i.e half of people get one test and half of people get another.)
Here is my current(not working) solution

wintry quarry
#

not the class itself

#

Also your data should not be static variables

#

they need to be nonstatic

stone pebble
#

Yeah, i get that, but i cannot make an object of the userData class that is accessible from all the different scripts that need to get to UserData

swift crag
#

you can have a static field that holds a UserData

#

or do something more elaborate

wintry quarry
#

either way you need an actual instance

swift crag
#

you'll need to be able to create an instance of UserData when you deserialize

#

so having all of the data in static fields doesn't work

wintry quarry
#

and actual nonstatic variables inside it

stone pebble
wintry quarry
#

stop using static classes

#

that's not what you want

#

and it won't work with serialization

swift crag
#

you'll replace every instance of UserData.foo with SomeoneWithTheData.data.foo

stone pebble
#

And what if some data that I need for the userData class lies in other scenes? Do I do a [DoNotDestroyOnLoad] even though all my scenes are loaded additively?

swift crag
#

Everyone will have access to the static field that holds the UserData instance

#

things will work almost identically to how they do right now

stone pebble
#

So basically instead of having a static class I'll have a static object of said class?

swift crag
#

A static field that holds an instance of the class.

#

but yes

stone pebble
#

Can i ask a stupid question?

#

What is the difference between a static object of said class and a static field that holds an instance of that class?

wintry quarry
swift crag
wintry quarry
#

the reference variable is static

swift crag
#

The static modifier on a class doesn't really do anything

wintry quarry
#

the objects instance is completely normal

swift crag
#

It just makes the compiler throw an error if your class has any non-static members

#

I guess it also stops you from constructing an instance of the class

#

But it doesn't enable anything new

polar acorn
#

Well, there's GameObjects marked static in the inspector blobtongue

buoyant knot
#

static effectively means it is a part of the class definition. it does not belong to any “thing” because there is no thing to own it

buoyant knot
#

don’t confuse the man

polar acorn
#

Yes ignore me I'm just being a pedant these concepts have nothing to do with each other they just share a name

stone pebble
#

so basically unity "static" is just a marker interface?

swift crag
#

no, this has nothing to do with the "Static" checkbox in the inspector

#

forget that

polar acorn
buoyant knot
#

god damnit now you confused him

polar acorn
#

You can sort of think of it as "belonging" the script file on disk, if that helps

swift crag
#

or maybe I've been confused instead 😭

buoyant knot
#

C# static means it belongs to the class definition

stone pebble
#

awesome

swift crag
#

You currently have a class with static members in it. This means that each of those members is part of the class, not a specific instance of the class.

The member is on the class, not the object.

polar acorn
#

there's only one file, there's only one thing with static fields and functions

safe root
#

How do I fix this error? I have it install but it says I don't

swift crag
#

You are going to make the members non-static. This means that the members exist on instances of the class, not on the class itself.

buoyant knot
#

if I make a class called circle, and define static float Pi, then Pi is now a member of the class. It belongs to the class and not any one circle

swift crag
#

You are then going to make a static field that holds an instance of UserData.

stone pebble
#

Basically I need a singleton. Whether it means making a static class or a static reference to an instance of a class (correct me if i said something wrong) doesn't matter

strong moth
swift crag
buoyant knot
swift crag
#

You can also serialize this instance to JSON. Then, you can turn that JSON back into an instance, and store the instance in the static field.

strong moth
#

thought you were asking a question mb

buoyant knot
#

if you make a singleton, which is a class with a static reference to one instance (that forces there to only be one instance), then the definition of your class contains a reference to the one instance

stone pebble
buoyant knot
#

a static class is one that cannot have instances, btw

#

static class means everythjng in it is static

stone pebble
#

When i have a public static class i can just assign variables directly from other scripts of mine

buoyant knot
#

woah, stop

#

that is not how you use static variables

stone pebble
#

Sorry

buoyant rune
buoyant knot
#

static variables are super dangerous because it is tied to the definition of the class. Anything can fuck with it, it is very hard to debug because it is hard to trace

#

yes you should use them, but only with great care

#

if you need to get a reference to an instance from various scripts, then you are probably looking for either a Singleton pattern, Service Locator pattern, an initialization method that gives your script the ref it needs when instanced, or a serialized reference

#

Singleton => class has exactly one instance => direct reference to it

swift crag
#

a static field that you write data to when saving sounds perfectly fine to me

buoyant knot
#

Service Locator => like a telephone operator, instance A asks the service locator for something, and the service locator gets it a reference to instance B

#

i just need to make sure he doesn’t abuse static variables, because that is an easy way to get into very deep shit

swift crag
#

I usually do this by giving the relevant components a "Save" method. The Save method is given an instance of your SaveData class, and the component writes data to the object.

#

You can either explicitly call the Save methods on the relevant components, or you can have the components subsribe to an "on save" event that you invoke when you want to save the game

stone pebble
#

From my understanding, since i just need to put all of my data into a single instance, and each script corresponds to certain fields/variables that will be assigned as the script does its job. The instance is then converted to .json and sent over. From my understanding I can just get away with a singleton pattern? Pls correct me if i am wrong

buoyant knot
#

yes

#

my save handler is a singleton

swift crag
buoyant knot
#

static classes are usually like toolboxes of functions to use. like System.Math and UnityEngine.Mathf

swift crag
#

notably, those static classes also generally don't have any state in them

#

they aren't remembering stuff from function call to function call

#

That's what can make static members dangerous, IMO

#

If calling SomeStaticClass.Whatever() changes what the method does the next time you call it, then anything in your game can indirectly interact with anything else in your game

swift crag
#

(that's part of why static members are so useful, of course)

#

you can shove data in a static field before a scene transition and read it later

#

you can completely blow up every single object in your game and reload the title screen and that data will still exist

stone pebble
#

Well, I'll check out what the singleton pattern looks like and how to figure out this logic. I'll write on my success/failure

buoyant knot
#

just get a Singleton implementation

nimble scaffold
#

UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <06837d428b6d46f581d93f9597703696>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <06837d428b6d46f581d93f9597703696>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

pls help guys

polar acorn
nimble scaffold
buoyant knot
#

Using this singleton looks like

public class MyClass : Singleton<MyClass> {
protected override void Awake() {
DontDestroy = false; // Or true, if you need don't destroy on load.
base.Awake();
}
}```
nimble scaffold
stone pebble
frigid sequoia
nimble scaffold
wintry quarry
#

Also this will only work for non-monobehaviours

#

seems like a general purpose C# singleton, not a unity singleton

frigid sequoia
nimble scaffold
#

i used cs

wintry quarry
#

it's presumably an Android build

#

Android apps are Java apps

nimble scaffold
#

yes

#

yess

stone pebble
wintry quarry
carmine turret
#

Is unities gravity meant to feel floaty?

wintry quarry
nimble scaffold
#

guys its my android game pls help i have to realease it rn

stone pebble
#

tbh i coded in c# for a couple years, and only recently actually properly learned OOP in college, so it is like relearning the language all over again

carmine turret
#

It definately feels like it has no acceleration when falling

wintry quarry
#

show your code

carmine turret
#

Im jsut using rigidbodies atm, sure thing

rich adder
stone pebble
wintry quarry
stone pebble
#

ok

carmine turret
#



public class movement : MonoBehaviour
    {
    public float speed = 300f;
    public float jumpForce = 1000f;
    private bool _jump;
    Vector2 move;
    Rigidbody2D rb;

    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();

    }

    void FixedUpdate()
    {
        if(_jump){rb.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);_jump = false;}
        rb.velocity = new Vector2(move.x * speed, rb.velocity.y);
    }

    // Update is called once per frame
    void Update()
    {
        _jump |= Input.GetKeyDown(KeyCode.Space);
        move = new Vector2(Input.GetAxisRaw("Horizontal"), 0);

    }

}

wintry quarry
# stone pebble ok

MonoBehaviours are C# classes that represent Unity components attached to GameObjects

wintry quarry
#

setting y velocity to 0

#

no wonder you fall slowly

carmine turret
#

Ahh. that makes sense, should I set it to rb.velocity.y?

frigid sequoia
nimble scaffold
#

guys anyother soln?

wintry quarry
carmine turret
#

Ohhh okay, sounds much more simply. thank you

stone pebble
#

@wintry quarry It looks like that when using .ToJson i can get away with a simple Serializable class. I haven't made a MonoBehaviour class even in my less complex builds and it worked

wintry quarry
#

Oh sorry you were also the singleton person

stone pebble
#

exactly

carmine turret
wintry quarry
#

I mean, the singleton thing you were showing was pointless/overkill

#

all you needed was a static variable initialized with new

#

I still wouldn't personally do it that way but that's the simplest approach

stone pebble
#

How would you personally do it?

buoyant knot
#

you want to be able to do the programming and logic once for singleton, make it as a generic, and then use it for different classes

wintry quarry
buoyant knot
#

the class I linked has cases for the application quitting, cases for monobehaviour vs not, cases for dontdestroyonload vs not

#

and if you later want to make it thread safe, then you now need to update like 20 classes or whatever, instead of modifying the singleton class that everything derives from

stone pebble
#

Yeah, ig i'll have to make the app actually production safe

buoyant knot
#

if you are too afraid to use a singleton because you are bad at documentation, then you need to get better at documentation.

stone pebble
#

Honestly I do not think I should care about thread safety? But it doesn't hurt

buoyant knot
#

you can't be a programmer who sucks at documentation. you will drive yourself insane

stone pebble
swift crag
#

thread safety is irrelevant when you only access the singleton from Update/etc.

wintry quarry
#

Unless you go out of your way in Unity, thread safety is not a concern.

swift crag
#

unity's update loop is single-threaded

swift crag
#

you have to explicitly try to wind up on another thread

buoyant knot
#

that's why my singleton doesn't have thread safety in it. But if you later change your mind and need to add it in, it is easier to do if you just need to fix one class and not 69

#

and that applies to any modification

#

if there is something about the Singleton you don't like, you just change it, and it follows to every class derrived from it.
that's why I'm not a fan of manually implementing singleton behaviour into a class, unless you have a case where you need to derrive from a non-singleton-derrived class.

stone pebble
#

A bit of an unrelated question, but did you already have another hopeless programmer come and ask you stuff to need a GitHub folder with data structures?

buoyant knot
#

yes

nimble scaffold
buoyant knot
#

you are not the first. you won't be the last

stone pebble
#

that is good to hear

weary finch
#

Early returns. Instead of

if(value != null){

}
``` do 
```cs
if(value == null){
  showerrror...
  return
}
nimble scaffold
#

my laptop is in a bad conditon and ig its my last opeing my laptop and still i cant publush my game 503error 😭😭😢😢😿😿🥹🥹

#

and yeah guys can anyone tell yes or now that wuld connecting my laptop throgh hdmi cable to my tv set top box work??

buoyant knot
shadow rain
#

hello how would change the value of a bool parameter in animation stuff? in a script

swift crag
shadow rain
#

ty

#

wait

nimble scaffold
shadow rain
#

thats what i i

#

did

weary finch
shadow rain
#

still thiss error?

wintry quarry
shadow rain
#

whoops

#

i know what i did

shadow rain
#

nice

#

ngl i feel im learning rlly fast

carmine turret
#

I am very mcuh not remembering the maths to do drag..

#

I was thinking of using lerp

#

but it stops instantly, which could either be my code, or the way im using lerp aha

#
        RaycastHit2D hit = VisualPhysics2D.Raycast(transform.position,-Vector2.up,groundedDistance, groundedLayer);
        if(hit){
            rb.velocityX = Input.GetAxisRaw("Horizontal") * speed;
        }
        else{
            rb.velocityX = Mathf.Lerp(rb.velocity.x, 0, horDrag);
        }
rich adder
#

lerp looks wrong

summer stump
#

Hopefully not a constant?

carmine turret
#

Not entirely sure what you mean by a constant, its just how much drag I want to use as a public variable

summer stump
#

But yeah, sounds like it is the wrong thing

carmine turret
#

Ahh yeah it is an unchanging value

#

multiplying it by time seems to help a bit

summer stump
#

The third parameter is supposed to change from 0 to 1 for what you are attempting

#

Oh, no, do not multiply it by deltaTime

rich adder
summer stump
#

I would look into MoveTowards or SmoothDamp

carmine turret
#

SmoothDamp sounds like it might be more correct

carmine turret
rich adder
#

but yeah you probab can just use the ones that dont overshoot like movetowards

carmine turret
#

I havent really tackled coroutines here

#

the recommended one in the link you sent does give a nice effect, but I will try the other two out shortly.

swift crag
#

there are two ways to use Lerp

#

One is to have a fixed start and end, and to vary t from 0 to 1

#

The other is to have a variable start and fixed end, and to pass a (roughly) constant value of t each time

#

The former gives you a linear movement from the start to the end.

#

The latter will give you something more like on that "wrong-lerp" page, where you start fast and end slow

carmine turret
#

I see

swift crag
#

Both are valid, but the latter is easy to do wrongly

#

the intuitive "just do Time.deltaTime times a constant" idea is framerate-dependent

#

SmoothDamp is great if you want to move towards a target with some damping

hot hill
#

i am using debug.drawline to visualize my velocity force when i start the game without moving the red line which represent the velocity is in this direction. Isnt it supposed to be 0 if we consider it a vector? (edited)

swift crag
#

You want DrawRay.

#

DrawLine draws a line between two points

#

DrawRay draws a line starting at a point and extending in a direction

shadow rain
#

ok so ive got 2 questions soooooooo how would i make the player model point in the x direction of the mouse and how would i make my anims play when the player moves?

rich adder
shadow rain
#

tysm

rich adder
shadow rain
#

i just dont want the player looking all weird

rich adder
shadow rain
#

ok so

#

the reason i want the player character only on the x is bc i dont want the model slanted or smth like that

#

at an angle

rich adder
#

so you only want a flip based on mouse pos? not aim towards mouse?

shadow rain
#

idrk

rich adder
shadow rain
#

it would be nice to make it rotate from the hip actually

#

might try that

#

is there not a thingy called lookat?

#

couldnt i do

#

new Vector3(Cursor.Lookat());?

rich adder
#

what I sent will look at the cursor

shadow rain
#

should i put it in a new script?

rich adder
shadow rain
#

okedoke tyty

#

should it be vector3

rich adder
#

or just copy how I wrote it with the casting, up to you

shadow rain
#

hmm ok ok

#

in the console it says screen point to world isnt a camrea thing

rich adder
#

check the edit

shadow rain
#

okeodke

rich adder
#

its ScreenToWorldPoint

shadow rain
#

oOoOOo tyty

#

hav u ever used any other game engines

rich adder
#

Game Maker, Source SDK, Unreal,Godot, Three.Js .. thats about it

shadow rain
#

lol what has happened

rich adder
shadow rain
shadow rain
#

im quite fond of roblox studio

rich adder
shadow rain
#

lol

rich adder
#

what kinda game are you making

shadow rain
#

i retro knight game

#

shaders

rich adder
shadow rain
#

fpv?

#

sry

rich adder
#

First Person View ?

shadow rain
#

ooft sry

#

shouldve guessed

#

never rlly saw that tbh

rich adder
#

if you want to rotate the player with the mouse You have to GetAxisRaw horizontal then plug that into the player Y rotation

shadow rain
#

alright

#

camera.getaxisraw?

rich adder
#

nah

#

Input

#

any FPS tutorial really has such a thing shown

shadow rain
#

ok

#

thats my camera script

#

could i not use that

rich adder
#

is this not already rotating player ?

shadow rain
#

only the camera

rich adder
#

what is Orientation

#

you shouldnt have to rotate both

shadow rain
#

i built of a yt vid

rich adder
#

once you rotate player on Y if camera is already as child it will rotate properly

shadow rain
#

is i put my character into camera it will rotate?

rich adder
#

then you can just rotate player on Y it will rotate cam on Y too

shadow rain
#

should i put cameraholder into player then?

grave zenith
#

could anyone help me with creating a ring of light around my player? its a 2D, top down project, i want the world to be completely black outside of the ring of light, i feel like ive looked all over for something similar but i cant find a thing. im reading that using Universal RP is the way forward but i've never used this type of lighting system before so im pretty lost

shadow rain
#

okedoke

rich adder
grave zenith
#

@rich adder is that a seperate package or is it included in Universal RP?

shadow rain
#

like that

grave zenith
rich adder
# shadow rain

yes you have to reference the correct transforms though

#

put script on player and change the fields to be Transform and do one for player and one for camera

#

Transform player
player.rotation = Quaternion.Euler(0, yRotation, 0);

shadow rain
#

got it working

#

i just put it into camera and did what u said

#

ty ty u r the goat

#

actually one more thing

#

how would i make the player model not phase through the camera

rich adder
shadow rain
rich adder
# shadow rain

yea you'd have to lower then camera Near from 0.3 to something lower, under Clipping Plane

shadow rain
#

what would u say to?

rich adder
#

you have to keep lowering until it works for you , I dont have an exact number lol

shadow rain
#

okedoke ill try it

shadow rain
#

u sure

#

its better when i make it higher

#

nvm

#

nothing rlly seems to work

#

no matter what i o

#

do

#

ahh

#

wait

#

it doesnt seem to work

rich adder
#

idk what any of this means?

shadow rain
#

yk how u said to lower

rich adder
shadow rain
#

it keeps clipping

rich adder
#

so put it even lower.

#

like 0.02 or something

swift crag
#

If the camera is stuck into your body, you're going to get clipping

shadow rain
#

now when i turn my camera it turns around th eplayers bod

#

body

rich adder
#

wait they are mis-synced

#

did you leave the rotation on the camera Y too ?

shadow rain
#

idk

rich adder
#

yeah that is hella wrong

shadow rain
#

okekode

#

what can i do to fix it then?

rich adder
#

please send code properly

#

so I can show

shadow rain
#

isnt it like !code

eternal falconBOT
rich adder
#

yes use the proper format

shadow rain
#

alright no problem

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

public class CameraController : MonoBehaviour
{
    public float sensX;
    public float sensY;

    public Transform orientation;
    public Transform player;
    public Transform camera;

    float xRotation;
    float yRotation;

    // Start is called before the first frame update
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
    }

    // Update is called once per frame
    void Update()
    {
        float mouseX = Input.GetAxisRaw("Mouse X") * Time.deltaTime * sensX;
        float mouseY = Input.GetAxisRaw("Mouse Y") * Time.deltaTime * sensY;

        yRotation += mouseX;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);

        transform.rotation = Quaternion.Euler(xRotation, yRotation, 0);
        orientation.rotation = Quaternion.Euler(0, yRotation, 0);
        player.rotation = Quaternion.Euler(0, yRotation, 0);
    }
}
rich adder
#

something like cs camera.localRotation = Quaternion.Euler(xRotation, 0, 0); player.rotation = Quaternion.Euler(0, yRotation, 0);

shadow rain
#

alright

rich adder
#

or you might need += for camera with eulerAngles

shadow rain
rich adder
#

why do you have so many

shadow rain
#

🤷‍♂️

rich adder
#

get rid of the first two lines as those dont make sense

#

the last two are more explicit on whos what

shadow rain
#

without transform i ant move left anr right

rich adder
#

are you sure you only removed the first two

#

did you assign the new two fields ?

eternal needle
#

If your rotation affects movement, your model is not centered

rich adder
#

ah yes, make sure pivots are correct with that too

wintry quarry
#

Has this person actually shown the inspector of the script and the hierarchy window to show which object is which and what's assigned where?

rich adder
#

good question , we should've probably did that first lol

#

@shadow rain show us the script and which object its on, with fields showing

acoustic crow
#

!code

eternal falconBOT
acoustic crow
#

Script: https://gdl.space/arevidahef.cs
Video: https://www.youtube.com/watch?v=k_pFMnqkgtw
Description: The issue, as seen in the video, is that when I start a world where I manually place enemies, they move along with the player and change position accordingly. However, when I try to spawn enemies in a different world using a spawner, intending for the enemies to fly towards the player's position, it happens that, as shown in the video, the enemies fly past and do not follow the player.

I want the enemies not to be behind the player but in front of the player, and as soon as one spawns, it should move towards the player and behave as shown at the beginning of the video.

I hope someone can help me 😦

void siren
#

Hello, I have some code that for some reason just won't work. The movement part of it is fine, it's just the part where it says stuff about colliding. When the bullet collides with an obstacle it doesn't destroy. I have box colliders on both of the objects (bullet and obstacle) with the bullet having "Is Trigger" turned on. Can anyone help?

#

The obstacle has the correct tag.

wintry quarry
wintry quarry
void siren
#

There is no way i did that lol. I triple checked everything 0.0

wintry quarry
#

In the future use Debug.Log to make sure your code is running properly

void siren
#

What's that?

wintry quarry
#

The first thing you should have learned when starting Unity

#

it prints a string to the console window

#

you should be using it to debug your code

void siren
#

Alright thank you

acoustic crow
#

@ bob ``` private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Enemy"))
{
Destroy(other.gameObject);
Destroy(gameObject);

 }

}```

#

try this

#

@void siren

wintry quarry
#

there's no need to change anything really except fixing the misspelling of OnTriggerEnter2D

void siren
wintry quarry
#

CompareTag would be slightly better though

void siren
acoustic crow
#

@wintry quarry what do you mean?

void siren
#

ty

shadow rain
wintry quarry
# acoustic crow <@179367739574583296> what do you mean?

I mean, you have a player reference that your script uses to follow the player. How are you assinging it when you spawn enemies in during the game?
if you're NOT assigning it, then naturally they won't know how to follow the player

polar acorn
rich adder
void siren
#

asdjasdasj ds leave me allooinen

rich adder
# shadow rain

alr why do you have 3 fields + transform.rotation one in the script

rich adder
#

so the script is on PlayerCam?

shadow rain
void siren
#

🤓 Uh, ☝️ bullying will NOT be tollerated!🤓

acoustic crow
#

@wintry quarry i have puplic gameobject player and i have a prefab that i used?

rich adder
wintry quarry
#

in code

acoustic crow
#

thats not true sorry

wintry quarry
#

It is true, sorry

#

If you think you have it assigned, show it

shadow rain
polar acorn
# void siren oh mb im slow

Just a roundabout way to explain why the spelling matters. Functions only run when something specifically calls them. Unity obscures this fact sometimes by calling functions of specific names at specific times, and therefore it is vital to get the spelling right, since naming a function OnTriggerEnter2d and then calling it on your own is fully valid C# code, which is why it's not actually an error

acoustic crow
rich adder
shadow rain
wintry quarry
#

that's not possible when you spawn a prefab

rich adder
void siren
acoustic crow
wintry quarry
acoustic crow
#

yes i know

rich adder
wintry quarry
acoustic crow
#

but what i must add

wintry quarry
#

just... you know... actually assigning it

#

this assumes you are using the script type directly for your prefab, not GameObject

rich adder
acoustic crow
#

ouu okey i try it i just see var the firstday

wintry quarry
#

If you use GameObject (you shouldn't), you have to use GetComponent to get the script component then assign

wintry quarry
void siren
wintry quarry
#

it's just shorthand for GameObject or EnemyScript

void siren
#

unless there is and I havent found it

wintry quarry
void siren
woeful smelt
#

hi, I'm trying to create a TMP_InputField programmatically:

TMP_InputField inputField = inputFieldGameObject.AddComponent<TMP_InputField>();

// ... code that adds the text component and placeholder ...

inputField.caretColor = Color.white;
inputField.selectionColor = new Color(0.0f, 0.5f, 1.0f, 0.75f); // blue selection
inputField.caretWidth = 1;
inputField.interactable = true;
inputField.enabled = true;

I need to create it via script because this is a content mod for a game that I like a lot, so I don't have access to the unity engine interface.

the input field itself is showing correctly but the caret cursor is not appearing... the blue selection is also not appearing when I select the text or when I press CTRL + A.
I can send the full code if needed. can someone help me?

wintry quarry
#

For use with Unity?

void siren
#

uh, idk how.... im gonna look for a vid rq

acoustic crow
#

bob you dont did that 🙂

#

i know

wintry quarry
wintry quarry
eternal falconBOT
void siren
void siren
woeful smelt
wintry quarry
rich adder
stone pebble
#

Hi! I am just dropping in to thank you guys for your help a couple hours ago(I am the person that wanted to shove a static class into a method). The singleton pattern worked really well and I ended up with 3 singletons to manage my data better. Y'all are great!

wintry quarry
#

the text area, the text object itself, etc

woeful smelt
#

ok, I'll check it

void siren
wintry quarry
#

and notice how it has the viewport and text component assigned etc

void siren
#

"In unity, open up windows, packages" what

wintry quarry
void siren
#

im not seeing and windows packages

#

any

wintry quarry
woeful smelt
void siren
#

vs coe

acoustic crow
#

PraetorBlue I apologize for saying your tip wouldn't work.

It works now thanks to you, thank you brother

@wintry quarry catspasm

woeful smelt
#

for me to use

rich adder
void siren
#

code

wintry quarry
void siren
#

i thought they were the same till u sent the links mb

woeful smelt
wintry quarry
woeful smelt
#

I need to do it using code

wintry quarry
#

I understand that. Doing it in code is going to be annoying

rich adder
#

might need to regen project files in External Tools after too

wintry quarry
#

Unity has prefabs to avoid that annoyance, but you're not using them so it will be annoying

woeful smelt
#

ok, thank you

#

❤️

wintry quarry
#

Honestly if you could use UI Toolkit it would probably be simpler

#

you could include the UXML and load it all from there
not sure if that's supported in whatever you're doing.

shadow rain
#

Im terrible in unity

void siren
acoustic crow
#

@woeful smelt do you use chatgpt? or you make this alone

wintry quarry
void siren
#

omg

#

im gonna sound stupid but...

#

where is preferences

#

0.0

acoustic crow
#

what do you mean?

wintry quarry
#

Oh also VSCode's integration is really just not as good as VS

wintry quarry
#

K, I'm just telling you

acoustic crow
#

Visuall Studio is perfect for Unity

wintry quarry
#

The Unity integration is much better

void siren
#

VS makes me want to cry when i use it

void siren
remote jacinth
#

Does anyone have a Korean font asset for me please? Because I can't convert with Text mesh pro

void siren
#

is there a link for evertything

wintry quarry
#

yes

acoustic crow
#

wtf i dont unterstand why they make it so complicated

void siren
#

ok, i looked in the edit thing 30 times

wintry quarry
#

Common theme you looking at something a lot and missing stuff 😉

eternal needle
acoustic crow
#

Install unity and then in the module you can add Visual Studio which will be installed automatically and I have no idea why they make such a fuss out of it with strange links and websites

void siren
#

not only unity

eternal needle
#

As do many people here

woeful smelt
cosmic quail
#

chatgpt may give terrible code that dont work

acoustic crow
#

// ... code that adds the text component and placeholder ...

i see this lol ...
Don't try to use chatgpt for something like that, learn it yourself, there's no point in having an AI close everything then you won't learn anything

woeful smelt
#

no, I added that comment

eternal needle
woeful smelt
#

so I don't have to send the full code here in the chat

rich adder
#

but OP prob has windows so idk lol

acoustic crow
#

@woeful smelt Just don't use Chatgpt for that 🙂 You won't learn anything

woeful smelt
#

you're making it look look like I just copied the chatgpt unfinished code and sent it here

rich adder
#

wouldn't be the first, many people do that lol

woeful smelt
#

I don't do it

acoustic crow
#

Yes ... Fivem developer daily shit lol

woeful smelt
#

the full code is just too big

#

here

short hazel
woeful smelt
#

the game has an official modding api

short hazel
#

Doesn't matter

slender nymph
rich adder
#

then they should have their own discord for modding no?

woeful smelt
woeful smelt
#

about creating a TMPInputField

short hazel
#

Prohibited content and behavior
[...]
Discussing the modding or decompiling of third-party projects.

slender nymph
short hazel
#

Even if they have an API and allowed modding, it's still not allowed to be discussed here.

slender nymph
woeful smelt
slender nymph
#

that isn't the only reason.

analog glen
#

Hello. I have this code to make light disapear and then appear while holding button f to make light flickering

        yield return new WaitForSeconds(0.45f);
        ww.SetActive(!ww.activeSelf);
``` it works in editor, but not in build
acoustic crow
#

code beginners is for beginners who develop games with the unity enginge and not modding for fivem or anything like that

woeful smelt
#

it's not fivem

rich adder
#

we need more context

wintry quarry
analog glen
# wintry quarry this has nothing to do with holding any buttons. Share the full script
    
{
    [SerializeField] GameObject ww;
    [SerializeField] GameObject ee;
    [SerializeField] AudioSource dzwiekswiatel;
    [SerializeField] GameObject rr;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.F))
        {
            StartCoroutine(B());
            StartCoroutine(C());
            StartCoroutine(D());
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            dzwiekswiatel.Play();
        }
        if (Input.GetKeyUp(KeyCode.F))
        {
            dzwiekswiatel.Stop();
        }
    }
    IEnumerator B()
    {
        ww.SetActive(!ww.activeSelf);
        yield return new WaitForSeconds(0.45f);
        ww.SetActive(!ww.activeSelf);
    }
    IEnumerator C()
    {
        ee.SetActive(!ee.activeSelf);
        yield return new WaitForSeconds(0.45f);
        ee.SetActive(!ee.activeSelf);
    }
    IEnumerator D()
    {
        rr.SetActive(!rr.activeSelf);
        yield return new WaitForSeconds(0.45f);
        rr.SetActive(!rr.activeSelf);
    }
}
``` There are 3 lights
wintry quarry
#

also making three different functions for three different lights is just wasteful

#

you could just put them in an array and use one function

analog glen
#

Could you explain bit more? Sorry I'm new to unity hah

wintry quarry
#

Update runs every frame

#

so every frame while the F button is pressed, you will be starting new coroutines

#

these will overlap with the other coroutines you already started

eternal needle
#

Add a debug to your coroutines at the start to see how many coroutines you are starting

wintry quarry
#

and cause chaos

woeful smelt
#

PraetorBlue had already helped me with everything I needed... but all of Just1n's messages made me feel bad... he keeps assuming things, like I just copied something from the chatgpt and came here, and also that I am programming mods for fivem? anyway, everything Just1n said to me felt like an attack and really didn't help in any way. Anyway, thank you for the help PraetorBlue. I'm leaving

analog glen
#

So how I can make light flickering effect that make light disappear very fast? Make variable that block running another for 0.45f?

wintry quarry
analog glen
#

very fast light flickering

wintry quarry
#

When?

#

while the button is held?

#

or somethign else

#

and do you want randomness?

#

or something else?

analog glen
#

I mean it not must be randomness just like it was it appears and then after 0.45 of secund it disapears and again again

wintry quarry
#

and do you want all the lights to follow the same pattern, or no?

analog glen
#

yes

wintry quarry
twilit pilot
analog glen
#

it make them appear. They are on default not active then it make it active and then again disappear

wintry quarry
#

And when you hold it should they continuously flicker on and off?

#

It's unclear

analog glen
#

There is a dark corridor. After using button f light starts to flicking so you can see there

wintry quarry
#

Since you're not being incredibly clear, my best guess is you want something like this:

[SerializeField] GameObject[] lights;
Coroutine flickerRoutine;

void Update() {
    if (Input.GetKeyDown(KeyCode.F)) {
      flickerRoutine = StartCoroutine(Flicker());
    }
    if (Input.GetKeyUp(KeyCode.F)) {
      StopCoroutine(flickerRoutine);
    }
}

IEnumerator Flicker() {
    while(true) {
        foreach (GameObject light in lights) {
          light.SetActive(!light.activeSelf);
        }
        yield return new WaitForSeconds(0.45f);
    }
}```
wintry quarry
analog glen
#

until you release it. After releasing it it stops

rich adder
#

the code they sent does that, try it

analog glen
#

okey

analog glen
#

Thanks

#

😄

honest vault
wintry quarry
#

or near 0

#

on the z axis

#

Part of the problem may be that you have offset set to zero on your script

honest vault
#

yea it worked i changed the offset z axis to -1 and it now works fine

#

thanks for the help

wintry quarry
#

and the inspector

analog glen
#
using System.Collections.Generic;
using UnityEngine;

public class Mechanika2 : MonoBehaviour
    
{
    int blokada = 1;
    [SerializeField] GameObject ww;
    [SerializeField] GameObject ee;
    [SerializeField] AudioSource dzwiekswiatel;
    [SerializeField] GameObject rr;
    [SerializeField] GameObject[] lights;
    Coroutine flickerRoutine;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    IEnumerator Flicker()
    {
        while (true)
        {
            foreach (GameObject light in lights)
            {
                light.SetActive(!light.activeSelf);
            }
            yield return new WaitForSeconds(0.05f);
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F))
        {
            flickerRoutine = StartCoroutine(Flicker());
        }
        if (Input.GetKeyUp(KeyCode.F))
        {
            StopCoroutine(flickerRoutine);
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            dzwiekswiatel.Play();
        }
        if (Input.GetKeyUp(KeyCode.F))
        {
            dzwiekswiatel.Stop();
        }
    }```
wintry quarry
analog glen
#

on empty gameobject

wintry quarry
#

Is the object ever being deactivated or destroyed? Are you changing scenes?

analog glen
#

no

wintry quarry
#

that's the only way I could imagine this stopping. Or maybe you put another copy of the script on something elsewhere

analog glen
#

it stays only sometimes

polar acorn
#

Search your hierarchy for t:Mechanika2

#

See if there's any other instances of this script in the scene

analog glen
#

Only that

#

meybe it stays that when you release button in wrong moment

modest dust
#

I would rather say, that you do not deactivate the light when stopping the coroutine

#

They may be currently active, so you'd need to deactivate them manually after stopping the coroutine

#
if (Input.GetKeyUp(KeyCode.F))
{
     StopCoroutine(flickerRoutine);
     foreach (GameObject light in lights)
     {
          light.SetActive(false);
     }
}```
#

i.e. you're stopping the coroutine when it's waiting to deactivate the light

#

You also have double if statements checking the same thing, so merge them together (light flicking & sound play)

void siren
#

how would i change this to make it spawn at a random y position rather than at the origin of the object

wintry quarry
rich adder
wintry quarry
#

something like this

whole isle
#

is there a way to change vairabled all at once instead of going each script one by one

whole isle
analog glen
#

thanks for help 🙂

void siren
#

wait so where would that go

wintry quarry
whole isle
rich adder
wintry quarry
#

ther may also be a hotkey

#

or Refactor -> Rename

whole isle
#

would it change the variable in other scripts aswell

wintry quarry
#

Yes that's the whole point

void siren
#

now the enemies are spawning but i cant se them

#

wait

#

1s

whole isle
void siren
#

yeah idk

wintry quarry
#

anything else would be a problem elsewhere

void siren
#

theyre spawning outside of the box i put 0.0

wintry quarry
#

is there a reason you expect them not to?

#

What min/max values did you put?

void siren
#

oh god

#

yeah i put a biiiig number

#

min 0 max 1080

#

lol

#

oops

analog glen
#

How I can use variable from another script into other?

rare basin
#

did you try googling it?

wintry quarry
void siren
#

alr works

wintry quarry
#

For example when you do dzwiekswiatel.Play(); you are accessing the Play() function from another script (The audio source)

void siren
#

ty for the 7th time today

wintry quarry
#

You can do the same thing with your own variables and functions

analog glen
wintry quarry
#

as long as you get a reference to it

analog glen
void siren
#

praetor, do you live in this channel

austere hedge
#

I am getting odd behavior with number inputs. Out of all the numbers, pressing 1 is the only key that gets triggered. Sometimes even "1" doesn't get triggered, and I have to hit stop and hit play again for "1" to work once again. Can I get some help on this please?

#

The behavior is the same whether I use the numpad or the normal numbers on the keyboard.

polar acorn
#

Are you getting any errors in your console, even in other scripts?

austere hedge
#

I only have the one script running on this scene, but there are no errors showing.

polar acorn
#

Show the full !code for this script

eternal falconBOT
tall delta
#

I don't really know much about the new input system, but if '1' is the only one that works. could that be related to the fact that that's the only one you enable?

austere hedge
#

Ah.

#

Forgot to enable the rest...doh.

#

That doesn't explain why it only "sometimes" worked though, but I'm going to enable the rest right now and see what happens.

void siren
#

whys this grayed out

polar acorn
void siren
#

how do i changf that

#

i wanna move it

polar acorn
#

Why

#

The position of a canvas doesn't matter

swift crag
#

This is correct.

void siren
#

right in the center of my screen

polar acorn
swift crag
#

The position of the canvas in the world doesn't really matter when it's in "Screen Space - Overlay" mode

polar acorn
#

what about it

void siren
#

i want it top left

swift crag
#

The canvas is drawn directly onto your screen after the camera renders.

polar acorn
#

The canvas's position is completely irrelevant

void siren
#

0.0

swift crag
#

press F with the canvas selected to focus the scene view camera on it and set it up as you desire

#

you can look at the game view to see how it's going to look in-game

austere hedge
swift crag
#

and is this in the game view or the scene view?

void siren
#

game

swift crag
#

do you have Gizmos turned on in the top right corner?

void siren
#

yeah

#

whats that?

#

i turned it off now theyre gone

swift crag
#

turn it off if you don't want to see gizmos

#

gizmos are used to visualize things like colliders

void siren
#

ah

swift crag
#

stuff that would normally be non-visible

void siren
#

so if that were to be public no one would need gizmos

#

with it turjed on

#

dumb question nvm

swift crag
#

"that"?

#

i don't know what "that" means

void siren
#

yeah im a bit brain dead

#

i meant the game

swift crag
#

i don't understand how the game itself could be "public"

void siren
#

downloaded

#

published

#

for others to dowenload

#

download

swift crag
#

Gizmos aren't included in the built game.

#

They only render in the editor.

void siren
#

anyywaayyyss lets not talk asbout this bc im sounding more and more stuodi

#

stupid

lusty flax
#

how do i make my LineRenderer tile my texture?

wintry quarry
frosty hound
#

You can start by uploading your !code to a bin

eternal falconBOT
tall delta
#

I assume that the ledge grab transition is true, while the 'any state' transition to the blend tree is true at the same time

granite atlas
#

can anyone familiar with Gorilla Tag help me?

frosty hound
#

If you're grabbing the ledge, you probably should have a bool that you're doing so, so it doesn't call it every fixed update.

tall delta
#

without know what trigger/bools etc, the transition are bound to, helping with this is going to be hard

lusty flax
#

my texture isn't tiling, after a certain point it just begins to stretch

silver timber
lusty flax
tall delta
#

and the conditions from AnyState to jumpBlenTree?

silver timber
#

in your textures import settings. select the texture asset in your project and then find the "Wrap Mode" settings in the inspector

#

@lusty flax

carmine turret
#

So. currently my character "sometimes" (very very rarely) gets stuck of youre going at exactly the right speed when hitting the edge like this. it "should" be slipping off as it normally does but isnt. is there an equivalent to capsule collider for 2d?

#

just gonna replace the raycast with it

tall delta
#

there is your problem, as long as grounded is false, you can go from any possible state to the jumpblendtree. but that's also a condition from ledge grab, casuing a loop. AnyState to jumpBlenTree should maybe also have the condition canGrabLedge = false, or something to that effect.

whole isle
#

my hearts was like this but i changed the vairable fullhearts to filledheats now it dosent show when its filled

whole isle
whole isle
carmine turret
#

otherwise people cant really help you

#

ew that is weird!

whole isle
rich adder
eternal falconBOT
carmine turret
#

!code

eternal falconBOT
carmine turret
#

beat me too it

#

paste the code properly so people can edit it and such ^^

whole isle
#

like that?

#

it was working before

#

when it was fullhearts

#

but once i change the vairable it dosent

polar acorn
#

Show the inspector of this object

silver timber
#

is the reference to the sprite still assigned? it probably got lost when you renamed the variable

whole isle
#

ahhh the image is gone

#

ok it works now lol soz for the trouble

silver timber
#

yea Unity saves what values you have set in the inspector using the name of each variable. When a variable name is changed the original value is lost unless you add the [FormerlySerializedAs("fullhearts")] attribute

swift crag
#

you need to reassign the reference after renaming the field

#

oops, i was scrolled back

carmine turret
silver timber
carmine turret
#

Actually dont worry, it doesnt seem to have a layermask argument

#

Ill just use circlecast ^^

#

thanks though!

lusty flax
#

how do I stretch a sprite in a LineRenderer? it works, but it's a bit squished which makes it look odd

silver timber
silver timber
# lusty flax material

do you want it to tile based on the distance of the line, or stretch regardless of the line distance?

lusty flax
#

(as in, it tiles the same but the image is 2x longer or smth)

carmine turret
#

I would like some opinons, Im starting work on a grappling hook mechanic and Im wandering if I should a. use a distance joint and set the target to click location, or b use a hinge joint and set a rigidbody at click location as the joint

silver timber
lusty flax
silver timber
lusty flax
#

using Texture Scale?

silver timber
#

yes haha set it to Tile and it tiles

lusty flax
#

yeah but i tried that before

#

the tiling thing works, but when I try to change the scale it just doesn't want to

#

First image has TextureScale.x = 1, and the second is TextureScale.x = 2

#

i just want it to stretch

silver timber
#

Can you change the tiling in the material?

lusty flax
#

I can't change it

silver timber
#

I don't know exactly why its disabled, but probably because it's a sprite shader. The line renderer is not a sprite renderer so you can just use a regular Unlit shader for your material

lusty flax
#

changing it to an unlit texture kinda broke it

silver timber
#

It needs to be transparent since your texture has transparency

lusty flax
#

oh wait

#

wait

#

yeah

#

transparent

silver timber
#

Also if the Texture Scale wasn't working before maybe it will now. The sprite shader might not have been playing nice with how the line renderer works. Texture Scale works for me with the Unlit shader

lusty flax
silver timber
#

show me the material inspector

lusty flax
silver timber
#

That shader has alpha clipping

#

Which means if the alpha of a pixel is above the "Alpha cutoff" value it will be fully opaque, otherwise it will be fully transparent

#

I can't see the full shader name but I'm guessing that's "Unlit/Transparent Cutout" when you want "Unlit/Transparent"

lusty flax
carmine turret
#

Is linerenderer the best option to draw a line with texture between two points (a grappling hook for example)?

#

Or is there another method

carmine turret
#

aighty

#

thank you

warped roost
#

!cs

eternal falconBOT
warped roost
#

!blender

eternal falconBOT
frosty hound
#

@warped roost There's no need to test out the bot. It works.

warped roost
hollow zenith
#

Is there an order in which I should be executing my scripts?

Would this be a good way:

void StartGame()
{
  InitializeObjects(); // creates instances of game systems like inventory system, player controller and their events.
  UIManager.Init(); // loads all UI elements and set them to Active which should execute all OnEnable functions which will subscribe to events
  LoadData(); // Load game data from save file if needed or just default starting data(like getting first character in the game)
}
eternal needle
hollow zenith
#

I found out the issue, apparently Awake and OnEnable are called in this order within their scripts.
So 1 script might call Awake + OnEnable while another only Awake.

eternal needle
hollow zenith
#

I was just trying to use this:

    private void OnEnable()
    {
        Game.Instance.areaManager.onAreaUnlock.AddListener(OnAreaUnlocked);
        Game.Instance.areaManager.onAreaActivate.AddListener(OnAreaActivated);
    }

    private void OnDisable()
    {
        Game.Instance.areaManager.onAreaUnlock.RemoveListener(OnAreaUnlocked);
        Game.Instance.areaManager.onAreaActivate.RemoveListener(OnAreaActivated);
    }

It was recommended to me many times, but it seems like a bad idea, I might as well use Init function instead of relying on OnEnable

#

Or I have to load all ui + data in correct order to make sure they can subscribe to all events.

lusty flax
#

how can i add a ton of objects to a list quickly without having to tediously go through them all individually (i have over 50 sprites to add)

lusty flax
teal viper
lusty flax
#

where should i have posted this (to post stuff like this there instead, next time?)

teal viper
lusty flax
#

kk

#

(i was confused cause there's no im-stupid-and-don't-know-how-to-use-the-UI-help channel) 😅

simple valley
#

how do i make my camera look speed the same when using a mouse and controller

#

because right now the mouse is way faster

teal viper
#

Add a speed modifier parameter that is different based on wether it's mouse or a controller.

wintry quarry
#

Note that this doesn't even make sense because you can move your mouse at any speed, they're not analogous control schemes

#

Also show your code

rancid tinsel
#

how does (vector2)transform.position differ from vector2.zero here?

wintry quarry
#

Because I bet there's a bug in it

rancid tinsel
#

*first line of both methods

simple valley
wintry quarry
simple valley
#

those are the only 2 scripts that involve the camera

rancid tinsel
#

!code

eternal falconBOT
rancid tinsel
#

i recommend gdl.space personally

wintry quarry
#

You would just do OverlapCircle at that point

rancid tinsel
north kiln
#

!docs

eternal falconBOT