#archived-code-general

1 messages ยท Page 79 of 1

heady iris
#

notice how each face is its own separate piece

#

if those faces were joined up, then you'd get a nice solid outline

#

but then the edges would not be sharp, since it would be smoothly blending the orientation of the faces

mighty juniper
#

issue is i imported them from the unity asset store as placeholders until i make proper models xD

heady iris
#

so yeah, highlighting looks good anyway

#

outline effects can be fiddly

#

here's the same effect done in Blender

#

you can see some funky parts where the effect breaks down

mighty juniper
#

yeah i see what you mean

heady iris
#

the HDRP outline effect I use duplicates the mesh and redraws it several times with slight offsets

#

very reliable, but also...probably not the fastest

steady moat
#

The best result I have seen didnt scale the model vertices to obtain the results but worked as a PostProcessing effect. Mind you, I never actually did an outline shader so I would not know if it challenging to do so this way.

heady iris
#

yeah, i cobbled it together from some tutorials and I only mostly understand it

mighty juniper
#

The same outline likely wonโ€™t work for the highlights either because itโ€™ll just extend each face outwards and look silly

heady iris
#

oh yeah, you wouldn't want that for a highlight effect anyway

mighty juniper
#

Is there any way I can do the opposite? As in hollow out the centre

#

So it leaves a box of sorts

heady iris
#

unclear

mighty juniper
#

instead of the one to the left a box like this of sorts

heady iris
#

ah, you're highlighting the space to move to

#

you want it to appear sunken?

mighty juniper
#

this is what ive currently got

#

i just mean instead of a solid box, a frame essentially

heady iris
#

ah, ok

#

I would just make a separate mesh for the frame

mighty juniper
#

Oh yeah i guess that'd work

#

maybe this sphere idea would work better

#

not sure

lusty zephyr
#

making it red

steady granite
#

sorry for the delay, I am on Unity 2021.3.10f1 and TMP 3.0.6 which seems to be the latest available version?

mighty juniper
thin aurora
mighty juniper
thin aurora
#

Not to mention you're more or less asking for an opinion rather than an actual problem ๐Ÿ˜„

mighty juniper
#

Well yeah, but you could say that about almost anything. And the description of the channel states ask questions and discuss, i know its not directly related to coding but i didnt see anywhere that fit better so i thought no harm in posting it here as no one was asking anything at the time anyways so i wasn't interrupting

thin aurora
mighty juniper
#

eh i guess so. I dont see why its a big deal though, i wasnt getting in the way of other conversations

thin aurora
#

I have these coding channels open alongside other channels, so if I see new messages I usually check them whilst working, should there be a question.

#

I understand it's not not as important now as if there were more conversations, but keeping it in the right channel is still easier for some people that might check these channels (also, the banner mentions general coding concepts in Unity, so it would be off-topic)

knotty sun
#

there are a number of null ref exceptions fixed of which this looks like one

heady iris
#

that error suggests it found an object that it expected to not exist

#

that looks like a C++ statement, which is very interesting to see in the unity console, lol

steady granite
heady iris
#

comparing the result of .find() to the end iterator

knotty sun
#

It's a C++ assertion checking for null ref

heady iris
#

yeah

knotty sun
#

backup your project first

thin aurora
#

Pretty sure reopening Unity fixes the problem too

steady granite
#

it does for the first time I enter play mode only sadly

heady iris
#

and it's specifically when you DontDestroyOnLoad the object?

steady granite
#

well, this is the line unity redirects me towards when I double click on the error...

knotty sun
#

I suspect it's a Marshalling problem. nothing you can do about it

steady granite
#

and disabling the DontDestroyOnLoad line seems to remove the error (obviously lots of more errors due to this requirement though)

knotty sun
#

and Scene Load/Reload?

#

Be interesting to see if you do an IL2CPP build and run that if you get the same problem

steady granite
knotty sun
#

if it's consistent behaviour under given circumstances it's a bug

steady granite
heady iris
#

do you have Domain Reload / Scene Reload disabled down in Project Settings > Editor ?

#

iirc it's under a label like "Enter Play Mode Options"

knotty sun
#

reload of static pointers

heady iris
#

this would be consistent with the issue going away for one play cycle after reloading the scene in the editor

knotty sun
#

indeed

steady granite
#

hmm, maybe unrelated but trying a IL2CPP build actually fails

knotty sun
#

oh, show error

steady granite
knotty sun
#

different problem, your build environment is not set up correctly

steady granite
heady iris
#

ok, so that's not the cause, then

#

i wonder if manually destroying this object as the game quits would fix the issue

steady granite
#

isn't OnDestroy called on scene destruction when quitting play mode?

knotty sun
heady iris
#

I'd think it would ignore those settings if you don't have Enter Play Mode Options checked

knotty sun
#

It looks to me like an artifact from the previous Domain (i.e. Play mode) may be causing the error

knotty sun
#

still greyed out

heady iris
#

The default is to reload the domain and scene.

knotty sun
#

need play mode options as well

steady granite
#

just tried all possibilities, does not seem to be related

heady iris
#

You can enable the Options checkbox and then uncheck the Reload Domain / Reload Scene checkboxes to disable those reloads

hollow kernel
#

in a 2d space how do i make a projectile from the player at the direction the player is looking at

knotty sun
#

i'm thinking leave Scene unchecked, just the Domain Reload

heady iris
#

unity will perform both the domain and scene reloads if you don't explicitly tell it not to

steady granite
steady granite
hollow kernel
#

and also the velocity is not added

knotty sun
hollow kernel
#

the velocity line

knotty sun
#

so either Bullet is null or the Find is not working

hollow kernel
#

oh wait its the bullet

#

ok now no error but also no velocity

knotty sun
steady granite
runic kestrel
#

Yo not sure if I'm in the right channel but I have a problem with a while loop. I'm not sure why but using an or operator in the while loop still requires both conditions to be true otherwise it won't stop and I cant figure out why

hollow kernel
steady granite
#

isn't Rigidbody2D.velocity meant to be modified via AddForce() only?

hollow kernel
#

nope

heady iris
#

unlockComb and Input.GetKeyDown must both be true for this loop to terminate

knotty sun
heady iris
#

having your forward vector be the zero vector is...interesting

runic kestrel
#

yea but why and is there a way i can terminate it with only one condition?

heady iris
hollow kernel
#

well then now how can i give it a forward velocity

heady iris
#

state, in words, what you want to happen

#

no variable names

runic kestrel
#

okay wait i think i understand ๐Ÿ˜”

knotty sun
heady iris
#

a useful tip

hollow kernel
heady iris
#

the negation of A or B is not A and not B

#

it is not not (A and B)

#

it also isn't not A or not B

#

of course, you could also just say not (A or B) and keep it simple :p

hollow kernel
heady iris
#

oh, yes, if it's 2D, that won't be terribly helpful

#

you want transform.up, most likely

#

select the shoot point in the scene view and look at the colored arrows

#

red - X - right
green - Y - up
blue - Z - forward

runic kestrel
#

thanks ๐Ÿ™

bright token
#

HFAmount is an ingame currency. I display it in the shop via text. If I change it from the HF script, attached to the text, the text changes accordingly. But If I change the HFAmount from this script shown: the text, nor the data, nor the HFAmount updates. I tried it all with Logging and this script doesnt change anything. Anyone knows what the reason is? (PullHero() is called when clicking a button to buy something)

steady granite
knotty sun
bright token
#

my script is attached to a button in the scene

#

not a prefab

knotty sun
# bright token

Are you expecting the change to HFAmount in that script to also affect data.HFAmount ?

knotty sun
#

wrong

bright token
#

so that on the other script i can take it back

#

yea well thats why im here

#

how do I do it then?

knotty sun
#

HFAmount will be a value type not a reference type so values do not carry over

steady granite
#

I assume HFAmount is an int, changing the HFAmount value will not change any other value

bright token
steady granite
#

so you have to manually reapply the new value to your data

knotty sun
#

do you know the difference between value types and reference types ?

bright token
#

i tried using SaveData(ref data) at the end of the if statement but it didnt work either

bright token
knotty sun
bright token
steady granite
#
HFAmount--;
data.HFAmount = HFAmount;

something like that

bright token
#

yes but in that script i cant type "data.HFAmount"

#

it says "data doesnt exist in current context" and if i put "GameData data" into the parameters the whole thing doesnt work anymore

steady granite
#

or I love to use setter events to keep UI updated

knotty sun
steady granite
#

yes because data only exists in your Save/Load methods, you will have to keep a reference to it in your script if you want to modify it elsewhere

knotty sun
#

So cache GameData in that script then you can use it

bright token
knotty sun
#
Game data localData;
void Save(GameData data) {
localData = data;
}
void PullHero() {
localdata.HFAmount--;
}

for example

bright token
#

hmm I see

#

i get it

#

but whats the Game data at first? you mean my class GameData?

elfin tree
#

how can I use .Find (or something else) to find an element in a list and call one of it's methods?
this is what i had: _bottles.Find( listBottle => listBottle == bottleToFindInList);

knotty sun
bright token
#

or did you mean "GameData"

bright token
#

ok :)

steady granite
elfin tree
bright token
knotty sun
# bright token ok :)

Difference is GameData is a reference object, HFAmount is a Value object. You need to research the difference in behaviour

bright token
#

the output of saved data is still 55 even tho it shouldve been lowered

steady granite
elfin tree
#

extra step ๐Ÿ˜›

steady granite
#

_bottles.Find( listBottle => listBottle == bottleToFindInList).YourMethodName(); ?

elfin tree
#

would that modify the one in the list or a copy of it?

#

but yeah that could be it

steady granite
#

Find returns the element corresponding to your condition, so you can call the function at the end of the Find() call

steady granite
elfin tree
hollow slate
#

hi, how can i resize my ui components during playmode

#

i want to do this like file explorer

steady granite
hollow slate
#

yes something like that

#

but i just need to resize just width

#

not height

#

to be more specific i want to resize scroll view

steady granite
#

What comes to mind would be :
-add a child game object at grab-able points
-add script on the child object implementing IBeginDragHandler, IDragHandler, IEndDragHandler
-start grab change parent anchor to left/right depending on child side
-during grab change parents width with mouse position delta
-end grab restore previous anchor

#

also maybe implement IPointerEnter/Exit and change your cursor to show you can change size when hovering this child

hollow slate
#

ok thanks

#

ill try that

astral relic
#

hello, i was wondering, unity animation editor can animate fields of scripts. how is that done ? does unity use reflection to change (lerp) the values or what, it should be sth else right ? otherwise that would be costy on performance

heady iris
#

I would expect it to be using reflection, since you don't have to recompile the game to change an animation.

astral relic
#

yea true

honest sky
#

is there a Rigidbody.gravityScale

#

or is it only rb2D.gravityScale

honest sky
#

Thanks ๐Ÿ‘

foggy dagger
#

how do you make a list of all bools used in running scripts?

manic chasm
#

make an array

#

or a list

#

bool[] listofbools;

#

listofbools[0] = bool1
listofbools[1] = bool2
etc

heady iris
#

note that you can't, like, grab a pointer to a bool in another component

#

so that it updates whenever the other component's bool changes

leaden ice
foggy dagger
leaden ice
burnt echo
#

Just wanted to say thanks for being my rubber duck, guys. Typed out a huge ass question, thought of something to try, it worked, deleted question. ๐Ÿ˜‚

heady iris
#

I've typed out several long questions and then just not bothered to send 'em

pastel grove
#

Hi all! I'm trying to generate a particle system purely through code, and it mostly works - except for when I try to assign a Light. Namely, the following simply does nothing; lights.light simply ends up being null. Does anyone know how it can be done, if at all?

heady iris
#

hang on, are you getting a NullReferenceException from the lights.light = new Light(); line?

#

or is lights.light null when you check it later

pastel grove
heady iris
#

hmm, it says it wants a prefab

#

it might misbehave if you give it a non-prefab

pastel grove
#

I realize Light is a component and components aren't meant to be instantiated like this, but you can't exactly generate prefabs on the fly.

heady iris
#

oh wait, yeah, of course

#

that's why

#

<-- brain fart

heady iris
#
var obj = new GameObject():
var light = obj.AddComponent<Light>();
pastel grove
#

Guess so. Seems somewhat roundabout though - and what happens when I destroy the GO?

heady iris
#

well, then there lights.light will be null again

pastel grove
#

And if I don't immediately destroy it, then won't I end up with a surplus light in my scene?

#

Sure I could disable it, but then again - so much clutter!

heady iris
#

Is there a reason you can't just have a prefab?

pastel grove
#

I configure the hell out of it in runtime anyways, so not needing to maintain a prefab would be a lot cleaner.

#

Also, can you even prefab a component like this?

heady iris
#

sure -- you can assign a prefab to a field as long as the prefab has that component type on it

#

(or, more generally, you can assign an object in the scene as long as it has that component type on it)

pastel grove
#

Eh, yeah - not doing it in the scene.

#

I try to stay in code as much as possible.

#

So doing that in the scene would mean also prefabbing the particle system.

wide pecan
#

Hey everyone. Is there a way to call a function if a specific function in inheritance script was called? For example inheritance script has AddItem function and if this function is being called, derived script would call OnItemAdded function.

heady iris
#

well, if you do go with a prefab, yes

pastel grove
heady iris
#

do you mean the parent type?

pastel grove
heady iris
#

e.g.

class Parent { }
class Child : Parent { }
wide pecan
heady iris
#

I would do this:

wide pecan
heady iris
#
public class Parent {
  public virtual void AddItem(Item item) { }
}

public class Child : Parent { 
  public override void AddItem(Item item) {
    base.AddItem(item);
    OnItemAdded(item);
  }
  
  public void OnItemAdded(Item item) { }
}
#

If each child type must implement OnItemAdded in its own unique way, then I'd make it an abstract function on Parent, and have the Parent's implementation of AddItem call it

pastel grove
#

As @heady iris said.

heady iris
#
public abstract class Parent {
  public virtual void AddItem(Item item) {
    OnItemAdded(item);
  }

  public abstract void OnItemAdded(Item item);
}

public class Child : Parent { 
  public override void OnItemAdded(Item item) { }
}
#

if Parent can exist by itself, then make it non-abstract and just make OnItemAdded an empty virtual function

wide pecan
#

Thanks, I'll try this

#

Thank you so much. This works even better than expected. I expected unity to have something built-in function that activated right when the parent class is called but now I can control when to call OnItemAdded

heady iris
#

no prob!

normal arch
#

so im making a script that uses an animation curve and the animation curve changes dynamically, which is working, but not the way i want.
When i make an animtion curve it defaults to an ease-in-out curve, which i don't want, i want just an ease-out curve, is there any way to change this?

leaden ice
#

and just assign it to that in Awake or whatever

normal arch
#

but wont it just change back to an ease-in-out curve every time i change it?

leaden ice
#

wdym

#

how are you changing it

#

share some details

#

code etc

normal arch
#

this is the part of the code

#
jumpCurve = new AnimationCurve(new Keyframe(0, currentSpriteFloorHeight), new Keyframe(1, currentSpriteFloorHeight + 1));
        heightCurve = new AnimationCurve(new Keyframe(0, currentFloorHeight), new Keyframe(1, currentFloorHeight + 1));
heady iris
#

iirc you can control the handles on the keyframes, too

leaden ice
#

looks like you're defining the keyframes yourself

#

so it will make whatever curve you're giving it there

normal arch
#

ok

leaden ice
#

there are more parameters you can give

normal arch
#

i see there are 3 overloads

leaden ice
#

scroll down

#

yes

heady iris
#

hmm, how do you directly add a Keyframe to the AnimationCurve?

heady iris
#

I guess you just make an array of keys, then set that property with it

normal arch
#

ok ty

heady iris
#

oh, duh

#

yes, go with the second AddKey overload :p

#

i thought it was a little weird that it didn't exist

leaden ice
#

You can contiinue to use the constructor too

#

it's fine

normal arch
#

so im not exactly that good with this kind of maths

#

so i dont even know what im doing with this

leaden ice
#

The tangent value is just the slope of the tangent

#

so 0 would give you a flat horizontal tangent

#

1 would give you a 45 degree upwards tangent
-1 is 45 degrees downward
infinity is a vertical line up

normal arch
#

ok

leaden ice
#

it's slope as in slope of a line (y = mx + b) where m is the slope

normal arch
#

like tan function i see

leaden ice
#

just a line function

#

Play with it a little you'll get it

#

I do wonder if I'm wrong and it's an angle ๐Ÿ˜†

#

not actually sure if it's slope or angle

#

but it's one of those

heady iris
#

it sounds like a slope

#

y = mx + ๐Ÿ…ฑ๏ธ

normal arch
#

where i learned it was y = mx + c lol

heady iris
#

c for constant

#

that does make more sense

normal arch
#

i think its a slope though yeah

heady iris
#

i guess some people do y = ax + b

#

so it got mangled together

#

anyway, i always mess up ease in/ease out

#

if you want it to start fast and get slow, you want the t=0 keyframe to have a high slope

#

and t=1 to have a zero slope

normal arch
#

thats what i want yeah

#

im still messing about with it

normal arch
#

well i did it

#

i don't know how

#

but i did it

heady iris
#

I think I'm running into a situation where I need to "inject some dependencies"

#

so as I described yesterday, I'm replacing my fixed "health" and "stamina" (and etc.) stats with scriptable objects

#

i have an asset for each kind of stat

#

that's working pretty nice! but there's one problem

#

sometimes I want to refer to a specific instance of that Stat SO

#

for example, I want the default cost for blocking with a weapon to be stamina

#

but I don't really have any way to access that...

#

I need to use a specific asset to provide the default value for the "block cost" field

#

so that I don't have to manually configure that every time

shell scarab
#

You donโ€™t have a way to access your stats!?

heady iris
#

That's the problem, yes ๐Ÿ˜›

#

It's actually almost never a problem. This makes it easy to have entities that, say, don't even have a healthbar

#

It might be too extreme of a design.

shell scarab
#

Unless youโ€™re talking about the literal object?

heady iris
#

well, by "instance", I mean the single object that's associated with a SO asset

shell scarab
#

Ah

heady iris
#

you can absolutely instantiate SOs

#

useful if you're doing...funky stuff

shell scarab
#

So how are you storing the stats in a way you cant access specific stats?

heady iris
#

just a public List<VitalValue> vitals;, where VitalValue is:

[System.Serializable]
public class VitalValue
{
    public Vital vital;
    [SerializeField]
    private float value;
    public float maxValue;
    public float decreaseTime;
    public float regenDelay;
    public float regenRate;

/* more stuff related to regeneration, calculating the current percentage, etc. */
#

and I have a dictionary of Vital -> VitalValue to look them up

#

This is very similar to what I was doing before

#

Vital was an enum

#

and I had a few named fields on the entity class

#
public VitalValue health;
public VitalValue stamina;
#

e.g.

shell scarab
#

Why cant you look up stamina?

heady iris
#

oh sure, I can

unborn merlin
#

guys
i have a problem

setting Time.timeScale to 0 and then to 1 resets a scene

heady iris
#

but I need to have the Stamina SO

shell scarab
unborn merlin
#

i'm not kidding

heady iris
unborn merlin
#

i checked twice

shell scarab
heady iris
#

So this is only really relevant when I want to have default configurations for things

#

e.g. by default, a weapon's block should cost stamina to absorb hits with

#

most weapons will work this way

shell scarab
#

So have a reference to a scriptable object and default it to stamina?

#

I guess itโ€™s hard without a lot of detail about your project.

heady iris
#

well, the default is the problem!

#

I'd have to get it from somewhere

shell scarab
#

Get it from the dictionary!

heady iris
#

with what key, though?

shell scarab
#

โ€œStaminaโ€?

heady iris
#

i guess I could just key it on string name and then accept that I have a little bit of hardcoding

#

it wouldn't be that bad

#

yeah

#

it would be a very small number of places that actually care about the name

shell scarab
#

I mean no hard coding really

#

why would you have to hard code it?

heady iris
#

well, where does that string come from?

shell scarab
#

The scriptable object name?

heady iris
#

right, but I'd have to directly type that string into the code

#

I think that, at some point, it winds up being inevitable

shell scarab
#

No you donโ€™t

heady iris
#

you have to identify the thing somehow

shell scarab
#

Well you do

#

But only once

#

Just have a public reference to an SO, and on start say if empty { SO = dictionary.stamina. That way if you want a different stat, it wonโ€™t replace it with stamina

heady iris
#

yeah

shell scarab
#

Defaults always gotta be hardcoded if itโ€™s not a value type no?

heady iris
#

yeah, it has to live somewhere

#

it's just a matter of keeping it nice and concise

swift falcon
#

can anyone tell me how to destroy stop ?:
public GameObject stop;
Destroy(gameObject);

normal arch
#

Destroy(stop.gameObject);

#

that's it

#

you weren't using the variable name

swift falcon
heady iris
#

or just Destroy(stop);, since it's already the GameObject

heady iris
#

it ~will~ run without causing any errors, I suppose ๐Ÿ˜›

thorny onyx
#
    {
        if (moveup == true && movedown == false)
        {
            Debug.Log("move up");
            transform.position = Vector3.Lerp(startpos, endpos,1f);

        }```
#

why is this moving instantly

heady iris
#

you may be expecting Lerp to smoothly move the object over time

#

this is not the case

#

Lerp smoothly picks a value between the start and end based on the third argument's value

#

0f = start, 1f = end

#

There are lots of packages and libraries that can do this lerping for you, which is probably what you were thinking of

simple egret
#

moveUp, moveDown - why do you have two? Can you move both up and down at the same time? You should only have one

heady iris
#

i imagine this is like how you ignore a move input if you're holding both forwards and backwards down

thorny onyx
#

yeah that was it

lusty zephyr
heady iris
thorny onyx
heady iris
#

every update, it will move a small fraction of the remaining distance

thorny onyx
#

i think itll be ok though

heady iris
#

here's my suggestion:

thorny onyx
#

yeah i got it to work

heady iris
#
public bool open;
public float t;
public Vector3 startPos;
public Vector3 endPos;

void Update() {
  t = Mathf.MoveTowards(t, open ? 1 : 0, Time.deltaTime);
  transform.position = Vector3.Lerp(startPos, endPos, t);
}```
#

the door opens in 1 second

thorny onyx
#

hmm

#

if i have any more issues ill go with that

#
        {
            Debug.Log("move up");
            transform.position = Vector3.Lerp(transform.position, endpos,0.15f);

        }
        if (moveup == false)
        {
            transform.position = Vector3.Lerp(transform.position, startpos, 0.05f);


        }
    }
    public void toggleMove()
    {
        moveup = !moveup;
    }``` this works pretty well
#

what do the ? and : operators do again

#

ik theyre a shortcut

heady iris
#

it's the ternary operator

#

condition ? ifTrue : ifFalse

heady iris
thorny onyx
#

oh yeah youre right

#

i can multiply by time.deltatime tho right

heady iris
#

that will make it move (a little less than) 15%/5% of the remaining distance per second

#

it's one of those things where it never quite reaches the destination

candid forge
#

i was wondering is there is a quick access of List<> variables through their attributes, kind of like

// pseudocode
class coordinate {
  int x;
  int y;
  int baba;
  ...
}

class implementation {
  List<coordinate> coordinates;
  coordinate a = coordinates.Find(coordinate.x == 1, coordinate.y == 0);
}
#

Something like this, i currently have a function with a foreach that looks through the list to find the object and return it and i'm wondering what would be a more efficient way of accessing, since this has O(n) efficency.

#

If there isn't what would be an efficient datatype compared to List?

leaden ice
#

Use a Dictionary if you want to look things up by a particular key

ocean river
#

i have collision detection on a moving object, and whenever it goes into some corner, edge or similar hes clipping through. (walls and stuff)

is there a way to prevent that?

im using 3d

leaden ice
#

What does "have collision detection on a moving object" mean specifically

ocean river
#

box collision

#

and the others are mesh collisions or some rotated planes

#

and he can like walk through edges and stuff

leaden ice
#

What does "box collision" mean.

Sounds like you have a Collider on it

#

But that's only one piece of the puzzle

ocean river
#

box collider

#

its a gameobject

#

like super mario

leaden ice
#

You need more than just a collider for your object to not move through things

ocean river
#

rigidbody it has

leaden ice
#

Please show and explain your whole setup

#

What components it has, what movement code it is using, etc

ocean river
#

these are components of the rigidbody player, he is moving around like some classic game, with velocity and transform.translate.
the box collider should stop the player from walking against walls and walk on the ground, but in more complex maps that have small rooms and edges he just clips through.

#

well, now the problem is, he clips through these grey planes from behind and edges and like i said before,

#

is there a way to prevent that from happening, so he wont just walk through?

muted helm
#

Does unity give a preprocessor directive for if the program is running in build mode instead of the editor? I would assume that's what UNIT_EDITOR_WIN is but it isn't clear to me.

hexed pecan
muted helm
#

Okay, thank you.

fickle vigil
#

hey,
im having trouble getting this level creator to work. it executes, but it's not putting an atlas PNG "atlas_#.png" in the output only the bytes file and the level text file.

there are 2 scripts involved im not sure which is creating the issues as no errors are produces also im quite new unity myself

tawny elkBOT
#
Posting code

๐Ÿ“ƒ Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

๐Ÿ“ƒ Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

fickle vigil
#

its from a template im using from the unity store "bizzy bee color by number"

potent sleet
#

dude did you even read the bot? no one gonna download textfiles tbh

fickle vigil
#

like that?

potent sleet
#

this is a 1000 lines

#

you put both of them together?

#

why do you wanna make readability a chore lol

fickle vigil
#

no i didnt put them together

#

should i ?

potent sleet
#

you really like scrolling a 1000 lines to debug something ?

#

so no it should be split as much /often as possible to do so

fickle vigil
#

i found no bug

#

i metioned im new right?

potent sleet
fickle vigil
#

i was told to post here

#

sorry

#

@potent sleet this is coming up in vs code

CS0246: The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)

#

my this is the issue?? i finally got itellisense working finding out its was a firewall issue so im trying to make up for lost time here too, this has been a long time unsolved problem for me

#

thats the other script

potent sleet
fickle vigil
potent sleet
#

and Color should already be in UnityEngine directive

#

not sure which script or line that is so I can't say

fickle vigil
#

the second one i posted. the template is old could it have outdated dependencies or?

#

keep in mind i didnt write this script its part of the template i paid for

#

the creators are i guess not maintaining services to help the buyers which sucks

gray mural
#

@fickle vigil using System.Drawing;

fickle vigil
potent sleet
#

Color is already in UnityEngine namespace

gray mural
#

maybe

potent sleet
#

maybe ? it's an absolute fact

gray mural
#

not absolute

gray mural
#

for me it is not absolute though

#

yep then

fickle vigil
#

so should i just remove that namespace all together?

gray mural
#

why?

potent sleet
fickle vigil
#

thats because it executes with no errors

potent sleet
#

you literally shared an error

gray mural
#

you sent one though

fickle vigil
#

its just doesnt produce the expect atlas png

somber nacelle
#

oh god, have you gone and done something dumb like mess with the compiler unity uses

gray mural
#

because it has errors

ocean river
somber nacelle
somber nacelle
# fickle vigil i dont think so

then explain namespace BBG.PictureColoring; because file scoped namespaces are a c# 10 feature which unity does not support

fickle vigil
gray mural
#

what do you mean?

#

what do you mean to stop walking?

#

you can do it in the script, so that game stops when he walks somewhere?

#

or is it an issue of physic material?

ocean river
#

why is that so hard to explain... he should not walk into a wall

#

he should not walk through that wall

gray mural
#

ah

ocean river
#

the collider should stop the guy fromw alking
into
that

#

sorry

gray mural
#

are those walls actually planes?

#

i mean

#

plane

#

not cube

ocean river
#

nope, boxes

#

hm

somber nacelle
#

can you show the inspector for those plane objects?

ocean river
#

but i also use some mario odyssey map to test... and in edges or corners he can just walk through

#

right.

somber nacelle
#

also why are you using such an ancient version of unity

fickle vigil
ocean river
#

because im making a game for the new 3ds

gray mural
#

it does not have rigidbody

fickle vigil
#

also vector2

ocean river
#

do all objects need one, like every?

gray mural
#

i mean not every

somber nacelle
ocean river
#

??

gray mural
#

ok, not every

ocean river
#

the boxes dont move

potent sleet
gray mural
#

but you need rigitbody here

somber nacelle
#

if it doesn't need physics then it doesn't need a rigidbody. just a collider is exactly what you want for something static

somber nacelle
heady iris
fickle vigil
ocean river
#

but why does the guy slip through edge or walk through that plane, from behind?

somber nacelle
heady iris
#

ah, I see

gray mural
#

try to use rigidbody on those planes without gravity

somber nacelle
gray mural
#

maybe you move it with transform.Translate?

fickle vigil
west elk
#

Hi! I'm storing scores in an array and trying to get a new array with the positions of the scores. for example:
scores = [ 10 , 30 , 20 ];
places = [ 2 , 0 , 1 ];

Anyone with an idea on how I could do it?

ocean river
somber nacelle
#

yeah transform.translate does not respect collisions

fickle vigil
#

Line 4 and 8 are the only exceptions threat are all color or vector2

heady iris
#

if you're getting an error on using UnityEngine;, then everything else is going to be hosed

gray mural
#

you mean dictionary?

somber nacelle
heady iris
west elk
west elk
gray mural
heady iris
# west elk Exactly

I guess I would sort the scores, then get the index of each original score in that new sorted list

#

(sort, then reverse, since you want high to low)

gray mural
#

like: 10 score => 3rd place, 20 => 2nd, 30 => 1st?

west elk
gray mural
#

so use dictionary

heady iris
#

this will not handle ties, though

heady iris
gray mural
#

yes

heady iris
#

for ties, I guess I would remove duplicates first

gray mural
#

use dictionary then

#

IndexOf in dictionary

#

yrDictionary[score] => rank

west elk
potent sleet
#

about the namespace

#

your script can't compile with errors

gray mural
#

don't you just need to order all the scores?

32 => 1st place
25 => 2nd place
2 => 3rd place
1 => 4th place
...

heady iris
gray mural
#

ok

#

then use LINQ OrderByDescending(x => x) method i guess

gray mural
potent sleet
#

prob overkill

somber nacelle
#

OrderByDescending would probably be more appropriate

gray mural
#

oh yes

ocean river
heady iris
#

you need to tell the rigidbody to move

#

rb.MovePosition or rb.AddForce, depending on how you're doing motion

#

or just setting rb.velocity

somber nacelle
somber nacelle
heady iris
#

It doesn't? I was under the impression that it did, huh

#

the documentation says that you teleport a Rigidbody by setting the transform's position

#

I guess that's just to let it interpolate

#

interesting, gotcha

somber nacelle
#

it's intended for a Kinematic rigidbody which won't collide with anything

leaden ice
#

My understanding is that it will cause a kinematic body to appropriately push things out of the way

somber nacelle
#

right, my explanation was worded poorly. a kinematic rigidbody will not be stopped by other colliders

fickle vigil
fickle vigil
potent sleet
fickle vigil
#

Hence โ€œBBGโ€ in namespace

heady iris
#

no

heady iris
#

line 8 is bogus in anything earlier than C#10

#

and Unity is on...C#9, if I recall correctly!

fickle vigil
heady iris
#

Yes. Because it's not valid.

#

You can't do that.

#

namespace Foo;

#

this is not valid in the version of C# that unity is using.

#

Change it to

namespace Foo { 
  /* code in here */
}
fickle vigil
#

Unity engine? Or bbg.picture.

heady iris
#

oh wait, that's line 6, isn't it

simple egret
#

The one that has the error underlined

heady iris
#

namespace BBG.PictureColoring;

#

did you mean to make that a using statement?

simple egret
#

Nah it's probably the namespace declaration, seeing that it comes from the asset

heady iris
#

oh, it's from the asset itself

#

...why is it using file-scoped namespaces, though?

simple egret
#

Probably, but wtf is up with the formatting of this file

heady iris
#

that would never work in unity

#

i don't think this is directly from the asset

hexed pecan
#

Is that even a script for Unity

fickle vigil
#

so now Iโ€™m not getting the same errors I think I had something wrong with my.net, so I was doing some different installs there and now the debugger is working in unity

#

I will share the debug console information one second

heady iris
#

it sounds like you've done a bunch of random stuff

#

you should probably slow down

simple egret
#
  • that asset is $75, and has a lot of negative reviews... I wouldn't have bought it myself
fickle vigil
#

Never mind I guess I canโ€™t copy and paste the debug console

#

Doesnโ€™t seem to be able to let you copy and paste

analog echo
#

I dont know if you can in play mode

fickle vigil
fickle vigil
# analog echo yes you can

So, when it says run in the bag on the left-hand side, it says select debugger.

It provides me with.net 5+ and .net core
.net framework 4x windows only.
C# godot
Then it seems to do nothing after that doesnโ€™t matter which I pick I donโ€™t understand what to do

simple egret
#

VS Code? The debugger plugin is deprecated and not supported anymore

fickle vigil
heady iris
#

The script.

#

Did you create that file yourself?

fickle vigil
simple egret
#

You can't use it yep

heady iris
#

it sometimes works!

fickle vigil
#

Well, no wonder itโ€™s not working then

heady iris
#

it's very wonky

fickle vigil
#

So everything Iโ€™ve been doing should be probably disregarded

heady iris
#

but the core problem here is that your script cannot work in Unity.

#

it uses a C#10 feature

fickle vigil
#

Right the core 10 feature being bbg namespace correct?

simple egret
#

Better use a supported code editor like Visual Studio 2022 or Rider, to be able to use the debugger. But that's not the issue here. Can't debug code that doesn't compile

fickle vigil
heady iris
fickle vigil
fickle vigil
heady iris
#

no, I was simply using "Foo" as an example name

simple egret
# fickle vigil Right the core 10 feature being bbg namespace correct?

File-scoped namespaces yes. Before C# 10 you had to do

namespace NameHere
{
  // Code goes here
}

But since C# 10 you can do

namespace NameHere;

// Code goes here

And the namespace applies to the whole file contents. It improves readability, as it decreases one level of indentation

#

But, Unity doesn't use C# 10, so you need the first way of doing things

heady iris
#

yeah, since you almost never put multiple namespaces in one file

clear moss
#

Is there any way to pathfind to the closest spot for the agent, but then stop?

simple egret
#

So whoever made that asset either 1. was on some experimental unreleased Unity version, or 2. not in a Unity project at all, and imported the Unity libraries in a standard C# project

heady iris
#

one thing that I noticed...

#

despite using the file scoped namespace

#

it's indented as if it wasn't

#
namespace BBG.PictureColoring;

    public class LevelCreatorWorker : Worker
    {
        #region Classes

        public class Settings
        {
#

I wonder if VS suggested that you switch to a file-scoped namespace

simple egret
#

VS won't as it's aware of the C# version being used, but VSC can be dumb enough to apply the wrong code fixes

heady iris
#

well, VS might also think it's on the wrong version :p

#

i used to have a problem where Unity wrote .csproj files with the wrong C# version...

#

9, ironically

#

but yeah, that's my guess

#

if you just turn that into namespace BBG.PictureColoring {

#

...and then add a matching closing brace all the way at the end

#

it should spring to life

analog echo
#

Sry for the late reply, here you have the error I get. If u need any else detail let me know.

Exception in transaction delegate, aborting transaction
System.NullReferenceException: Object reference not set to an instance of an object
  at NoticiasDBManager+<>c.<Start>b__1_1 (Firebase.Database.MutableData data) Exception in transaction delegate, aborting transaction
#

The code if someone wants to chek it out ๐Ÿ™ƒ

fickle vigil
heady iris
#

Visual Studio will let you debug it.

fickle vigil
simple egret
soft pike
#

Hey guys I am currently working on a simple Dialogue System.
In a nutshell every Guest Dialogue will have an NPC response and vice versa.
However the inspector doesn't let me add elements after a certain point. Any thoughts?

leaden ice
heady iris
#

i would suggest breaking this up so that each state in the dialogue tree is its own SO

#

and you just link them together

leaden ice
#

Seems like not a scalable system anyway

heady iris
#

this will make you very sad very quickly, yes :p

simple egret
#

It's going to be a 180ยฐ answer but I would make a graph editor for this kind of dialogue system

leaden ice
#

Like that's just not readable

#

Also you won't be able to make branches that return to the main dialogue branch etc this way.

A graph representation is definitely the way to go

fickle vigil
#

Question, my Mac has file vault turned on with that be causing problems because I keep getting a message coming up that says certain files and bundles canโ€™t be open because Apple cannot check it for malicious software and this is happening when I load up the project

heady iris
heady iris
#

but I've never experienced it in the unity editor

analog echo
fickle vigil
simple egret
# heady iris i need to look into making custom graph editors

Someone even made a sort-of programming language for that kind of thing and described it in their devlog. It had markers so characters would look at each other when talking, crazy stuff! I don't remember the publisher though, and I think it was closed-source

fickle vigil
#

Itโ€™s probably because Iโ€™m using that template

heady iris
#

maybe it also puts markers in the text to tell the game when to spawn items! [74] [74] [74] [74] [74]

#

ooh, prismatic shards!

#

stardew valley is a lovely game, but it can be very janky from time to time :p

simple egret
#

Oh, and it could also drive animations to represent emotions lol

#

All this from a text file a non-developer would create, and they made a parser in Unity

soft pike
soft pike
soft pike
soft pike
simple egret
analog echo
simple egret
#

Okay so your query there doesn't return any value

analog echo
#

but when it worked, it loged (Debug.Log(cantNoticias.Count)) it gave me 4

simple egret
#

So the first time this thing is called, the system isn't ready (?) and you get a null instead of your dictionary

analog echo
#

right, but when I opened the project I did the same as always and it worked

#

but now it doesnt

simple egret
#

I haven't dealt with Firebase from C# so I can't tell where the issue comes from

analog echo
#

Np, thx

simple egret
#

Anyone experienced with it lurking here, feel free to chip in

analog echo
#

So when I stay afk a Unity procces started and when it finished it worked, im going to try to screenshot it if I see it again

analog echo
leaden ice
quaint rock
#

would assume its a case of they had to stop somewhere, and ensure it does not get stuck forever if it hits a self referential data structure

simple egret
#

When it was first created, recursive functions were not a thing. So they agreed on a number they picked at random

leaden ice
#

Yeah probably a crude infinite cycle prevention mechanism

#

Also... to avoid the inspector looking like... well.. worse than that

quaint rock
#

if you need to go deeper there is a alternative now anyways

#

SerializeReference

fickle vigil
analog echo
simple egret
#

Hm where did you have that lol?

analog echo
#

at the end of the lambda

#

it worked with another script so I just copied and paste xD

simple egret
#

Yeah that'll do it. Still no idea why it worked some time and not the other time. It probably never worked

analog echo
#

well, ty anyways ๐Ÿ˜

steady granite
#

I'm not used to work with 3D, can you help with gimbal lock? Here's how I apply my rotation from mouse/stick to the camera:

    private void Camera_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        Vector2 delta = obj.ReadValue<Vector2>();

        // Create Quaternion rotations for each axis based on joystick input
        Quaternion rotationX = Quaternion.AngleAxis(delta.y, Vector3.right);
        Quaternion rotationY = Quaternion.AngleAxis(delta.x, Vector3.up);

        // Combine the two rotations to get the final rotation
        Quaternion finalRotation = rotationY * rotationX;

        //camera.transform.Rotate(finalRotation.eulerAngles, Space.Self);
        camera.transform.rotation *= finalRotation;
    }
#

heres how it looks (or is that not what gimbal lock is?)

leaden ice
steady granite
#

and yes it does work ๐Ÿ˜…

empty crystal
#

Anyone know if there's a way to programmatically convert a texture (NOT Texture2D) to a sprite?

haughty bison
#

Unity directional light. 3d objects are lit up on one side but completely black in the other. Is there a solution or does unity just suck? Cuz I can't get anywhere with this garbage

#

On the other*

shell scarab
#

so many small issues when just parenting it.

shell scarab
# steady granite I'm not used to work with 3D, can you help with gimbal lock? Here's how I apply ...

I don't rotate my camera with Quaternions not only because I don't understand them well enough, but because to my understanding they take the shortest path in rotation which is not always what you want to move because it'll rotate around the Z axis also. This is what I do:

rot = Vector3.Slerp(Vector3.zero, new Vector3(-delta.y, delta.x, 0), Time.smoothDeltaTime);
Vector3 newRot = _head.localEulerAngles + sensitivity * rot;
if (newRot.x > 89 && newRot.x < 180)
  newRot.x = 89.5f;
if (newRot.x < 271.5f && newRot.x > 180)
  newRot.x = 271.5f;

_head.localEulerAngles = newRot;

I do this on an input action, and have the camera follow the position and rotation in LateUpdate

swift falcon
shell scarab
#

can you elaborate more?

#

Slerp is not only "something for quaternions", there's literally a Vector3.Slerp method. It's for rotation.

#

and the vector3 shortest path vs the quaternion shortest path is different, so a quaternion's shortest path might wobble weirdly in my experience

#

I'm not sure that shortest route behavior is a thing with Quaternion.AngleAxis, but with .Slerp it definitely is, you can't force a direction with .Slerp to my knowledge.

swift falcon
# shell scarab can you elaborate more?

The issue with other axis' being affected from a lerp is a eular angles issue not a quaternion one that's because quaternions can't gimbal lock. And if I had to guess the slerp function for Vector3's is just a version that converts the eulars to quaternions and converts back

shell scarab
#

also don't guess

#

Vector3.Slerp is for interpolating directions, not positions.

swift falcon
#

there's also a quaternion.slerp function what do you think that does?

shell scarab
#

quaternion.slerp interpolates rotations

swift falcon
#

it's doing the same thing as the vector one but instead vector3.slerp is converted to eular

shell scarab
#

it's not doing the same thing as Vector3.Slerp

swift falcon
#

๐Ÿ’€

shell scarab
#

quaternions don't have a direction it's just a rotation

#

just ๐Ÿ’€?

#

one interpolates directions, one interpolates rotations.

#

as far as I know these are different. I'll look at the unity C# reference right now to see. But now I don't trust you to explain to me how they're the same or different based on your response of only an emoji.

swift falcon
#

well I mean I am also busy

shell scarab
#

I know what gimbal lock is but Vector3.Slerp is not rotation

#

it's for directions. Quaternions don't have a direction

solar jolt
#

anyone have any experience using beebyte obfuscator? had a couple of questions about it and there are no video's/debugging/resources to drill into for it.

haughty bison
#

So unity is trash then? Ok thanks.

quartz folio
haughty bison
#

Nope

#

Unity is just bad. The constant depreciation of things people find useful. Taking away good things it had.

shell scarab
#

lol what

quartz folio
#

Unity is one of the slowest at deprecating things out of any software I've used

cold parrot
#

someone is using non-LTS

shell scarab
#

I swear it feels like there's things that have been marked as depreciated for years and still not removed

quartz folio
cold parrot
haughty bison
#

For one progrids isn't available anymore. And u would think at the very least they could have just made it part of unity

shell scarab
haughty bison
quartz folio
#

Progrids is still available.

haughty bison
#

I'll check again

quartz folio
#

Just add it via name com.unity.progrids

cold parrot
languid hound
#

Is there a way I could get Lerp / SmoothDamp to work while time is set to 0

quartz folio
#

Lerp(0, 1, 0.5); // 0.5

languid hound
#

Oh right yeah brainfart uhh my bad

#

Thank you

quartz folio
#

No "job" posts or troll posts please

shy turret
#

Is there a channel for that

#

I was too lazy to look so ima just wait till someone helps

quartz folio
#

!collab

tawny elkBOT
shy turret
#

I require some 1 on 1 save system assistance,

quartz folio
timid meteor
#

Would this work to call a script from a gameobject called autohandplayer?

mossy snow
#

no, because it's searching by tag

timid meteor
#

ah I just realized that nvm XD

#

thanks

timid meteor
mossy snow
#

yes, but be careful with that. Searching by name is awful and if there are multiple GOs with the same name, there is no guarantee which you might get back

languid hound
#

Anyone know why this SmoothDamp isn't.. smooth?

#

Don't know what I did but its fixed. Moves to 0, 0, 0 though

#

Jesus christ I didn't multiply forwards

#

Nope that doesn't matter

quartz folio
#

a = SmoothDamp(a, b, ...) would work fine

#

If you for example smoothdamped your direction vector, and added that to your position it would work fine

languid hound
#

I see that makes sense I'll try that now

#

Worked perfect thanks!

solar jolt
#

this one is a mix of buildpipeline and shaders, is there a way to avoid compiling any shaders for a build, i.e. avoid my always included shaders?

#

I want to build a console window but shaders appear to still be added

late gyro
#

what is the best way to do tile collisions? currently using custom physics shape, but it's so much god damn work

topaz gate
#

Can someone please explain why my Input.GetKeyDown(Keycode) function thing dosent work ?

#

private void Update()
{
if (Input.GetKeyDown(KeyCode.F))
{
ChangeProjection = true;
}
}

steady moat
topaz gate
steady moat
#

Are you sure you correctly enable the Active Input Handling to Both ?

topaz gate
#

I am not sure

steady moat
#

The setting should be in Player Settings.

topaz gate
#

i did update the unity version last year

steady moat
#

Project Settings -> Player -> Other Settings as I read on Internet.

topaz gate
#

Ok ill look

#

I cant find or see it

steady moat
#

I am sorry, this is as far as I can guide you.

topaz gate
#

Oh ok

spare dove
#

Is gameObject.Find("Stuff") so bad that it's illegal, or is it fine to use it in functions that happens every now and then? ๐Ÿค”

potent sleet
solar jolt
# steady moat Use AssetBundle which does not include the shader. Alternatively, look into http...

Hoping this does the trick

internal class ShaderDebugBuildPreprocessor : IPreprocessShaders
{
    public int callbackOrder => 0;

    public void OnProcessShader(
        Shader shader, ShaderSnippetData snippet, IList<ShaderCompilerData> data)
    {
        switch (BuildPipeline.CurrentBuildType)
        {
            case BuildType.Host:
            case BuildType.Client:
                break;
            case BuildType.Server:
                data.Clear();
                break;
                
            default: throw new ArgumentOutOfRangeException();
        }
    }
}```
lean sail
#

Is there a general guideline for when I should be putting scripts on the player vs when it should be on an object? For example, I want a script for buttons controlling a spaceship, the player is on the spaceship.
There will be a trigger for when the player is in the ship and then the buttons themselves will need to affect the ships velocity, which leads me to think the script should be on the object.
But I also need to account for player input, which makes me think it should be on the player
Basically should the player detect the box trigger, or should the box trigger detect the player?

solar jolt
#

You can approach this several ways.
One way is if this is a script that can alternate from one ship to the next then make it ship dependent otherwise you could have it as an input profile that you can switch on and off the player.
So you have one profile for normal input and one for ship input, technically you could use this approach for all forms of input, i.e. switch to normal 3rd person/1st person input when not in a vehicle, switch to ship input when in ship, switch to land input when in land vehicle.

steady moat
#

In other words, you should be able to control the ship without the usage of input. It can become handy to follow such paradigm in the event where you have multiple target (Avatar, Spaceship, Menu) and source (AI, Cinematics, Player, Multiplayer, Online)

lean sail
lean sail
steady moat
# spare dove Is gameObject.Find("Stuff") so bad that it's illegal, or is it fine to use it in...

You should always other means to find GameObject. The usage of Find("...") breaks easily whenever you rename or reparent object. It can be a nightmare to maintain whenever your project starts to take complexity. Also, this is not an efficient way in term of performance.

Reference is a good way to manage those type of needs. It can also be done with GetComponent if needed. Tag, Singelton, ServiceLocator or Depency Injection are all valid ways to operate.

steady moat
#

This is the Dependency Inversion Principle.

solar jolt
# lean sail Thanks this cleared up a lot even for simpler interactions

a crude way of having this work is the player has an input interface

{
    void WKeyInput();
    void AKeyInput();
    void SKeyInput();
    void DKeyInput();
}```
then when you create different inputs they can implement this interface and this can be inserted into the player as a 'ShipInput', 'LandVehicleInput', 'FirstPersonInput'
```public ShipInput : IInput
{
    void WKeyInput()
    {
        // Move Forward.
    }
    void AKeyInput()
    {
        // Rotate Left.
    }
    void SKeyInput()
    {
        // Move Back.
    }
    void DKeyInput()
    {
        // Rotate Right.
    }
}```
```public Player
{
    [SerializeReference] IInput input;
}```
lean sail
# steady moat

Oh I see, thanks for the image! Im still new to unity but i know a good amount of c# so Ill look more into this

steady moat
lean sail
#

Yea ive heard of it but its been awhile

blissful frost
#

hello i am trying to shoot raycast out of a car gameobject can anyone direct me to some code or somehow explain how to shoot them out(im new to raycasts)

#

ping if you can help

lean sail
solar jolt
lean sail
blissful frost
#

how do i make it shoot out rays in other directions not just up and forward

lean sail
#

the input is a vector, you can choose the direction by just making a new vector3(x,y,z) direction. If you want a dynamic direction like the forward direction of the car, you can just take the objectName.TransformDirection(Vector3.forward)

blissful frost
#

how do i make the raycast start a little more up?

solar jolt
solar jolt
lean sail
#

Lol I actually used transform.forward in one script but TransformDirection(Vector3.forward) in another, oops

lean sail
blissful frost
#

how would i do that?

#

Vector3(car.transform.position.x, car.transform.position.y + 3, car.transform.position.z)

#

i tried this but now worky

lean sail
#

Do you know vector math or are you asking specifically about doing it unity?

blissful frost
#

in unity

#

transform.position(car.transform.position.x, car.transform.position.y + 3, car.transform.position.z

#

hb that

#

with a ending parantehses i forgot

leaden ice
#

You're just kinda making up syntax as you go eh

lean sail
#

U can just add vectors in unity with the + symbol the same way u add numbers

blissful frost
#

i need to know how that would like in code

#

i not good at c# learning sytax as i go

solar jolt
leaden ice
lean sail
lean sail
blissful frost
#

would i say like Vector3 offset = new Vector3(0,3,0) if im trying to be three units higher?

lean sail
#

yes thatll work but also i just wrote it as a new variable to show it, there are still other ways to add like said above Vector3.up * 3;

blissful frost
#

Now how would i make it slighty downwards

lean sail
#

That is left to the reader as exercise

solar jolt
blissful frost
#

so do you guys know how to make it go downwards

leaden ice
#

Think about it for a minute

solar jolt
#

we'll wait

leaden ice
#

I think you can figure it out

lean sail
#

I believe in you, if up is positive then...

marble halo
#

So I'm trying to make it so you can pan the map around by clicking and dragging, but for some reason it pans in the x and y axis rather than the x and z axis.

#
    {
        PointerEventData pointerData = (PointerEventData)data;
        Vector2 position;
        RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)canvas.transform,pointerData.position,canvas.worldCamera, out position);

        camView.transform.position = canvas.transform.TransformPoint(position);
    }```
#

how do i make it pan in the x and z axis?

blissful frost
#

not if its going up or down

#

how do i make the ray shoot out at an angle from the origin

lean sail
#

I would really recommend you look at vector math. the vector is the direction

        if (Physics.Raycast(transform.position, -Vector3.up, out hit))
            print("Found an object - distance: " + hit.distance);
leaden ice
blissful frost
#

ik

leaden ice
#

Vector3.down exists BTW

blissful frost
#

but how do i tell it to go at a certain angele forward

leaden ice
#

What certain angle

#

What does "certain angle forward" mean

#

You have to be specific

blissful frost
#

like that

#

like forward and down 60 degrees

leaden ice
#

I have no idea what that picture is showing lol

lean sail
#

Ok good you have drawn what i was going to explain, all those lines you have drawn are vectors, they are not angles

leaden ice
#

Anyway you can always rotate a vector by multiplying a quaternion with it

#

If needed

leaden ice
#

By multiplying a quaternion with it

#

With the * operator

blissful frost
#

agian i very new with with syntax and need a example code

leaden ice
#

q * v gives you v rotated by q

#

Literally with * like I said

blissful frost
#

what is q?

leaden ice
#

A quaternion

#

Like I said

blissful frost
#

bro

lean sail
#

Before getting into that honestly just experiment with plugging in random values lol. Quaternions are hard to understand at first, and honestly i dont think you know vector math to begin with

#

Like see what happens when you use idk (-1, -1, 0) as a direction

blissful frost
leaden ice
#

Doesn't work that way

blissful frost
#

ik

#

thats y i ask for more explantions

leaden ice
#

Quaternion goes first

blissful frost
#

not just thats what i said

leaden ice
#

Vector second

blissful frost
#

what is quaternion??

#

how would i describe it

leaden ice
#

It's just a variable that represents a rotation

#

That's all

blissful frost
#

how would i represent like 45 degress down?

leaden ice
#

Like a vector3 can represent a position

#

"down" is not a rotation

blissful frost
#

vecotr3(x,y,z)

leaden ice
#

So that doesn't make sense

blissful frost
#

hb a quternion

leaden ice
#

Quaternion.Euler(x,y,z)

#

Where those are angles around those axes

#

Or use Quaternion.AngleAxis

#

Where you provide an angle and an axis

blissful frost
#

Quaternion.Euler(x,y,z) * Vector3(x,y,z)

#

explain how to do that

lean sail
#

Honestly quaternions are going to confuse you too much right now. I would really just say experiment with plugging in random vectors to see where the raycast ends up.

blissful frost
lean sail
#

Like when you say at an angle, do you really need it at a specific angle or do you want it just angled down

blissful frost
#

angled down

#

not fully facing down but at an angle

lean sail
#

yea just go for random values, look at quaternions after you actually understand vectors

blissful frost
#

how do i put in thos random values?

#
            print("Found an object - distance: " + hit.distance);
            Debug.DrawRay(car.transform.position + offset, car.transform.TransformDirection(Vector3.forward) * hit.distance, Color.yellow);```
lean sail
#

Think of random values and put them into a vector

blissful frost
#

thats my code for forward raycast how would i make it go down

#

just pot me in the right direction

lean sail
#

idk if you saw but someone corrected my code i provided, you can just use car.transform.forward instead of what i wrote
For the vectors, the docs say

Vector3.forward
Shorthand for writing Vector3(0, 0, 1).```

Vector3.up
Shorthand for writing Vector3(0, 1, 0).

#

Really, just look at vector math already itll make sense

blissful frost
#
_rotation = Quaternion.Euler(car.transform.rotation.x, car.transform.rotation.y-1, car.transform.rotation.z);

_rotation * car.transform.TransformDirection(Vector3.forward)```
#

does this work?

plucky karma
#

car.transform.rotation is not a euler angles. Use localEuler.

What are you trying to do here? Why not just cam.transform.forward?

solar jolt
# blissful frost ``` _rotation = Quaternion.Euler(car.transform.rotation.x, car.transform.rotatio...

Here I got ChatGPT to answer it for you

If you want to get the resulting forward direction without actually rotating the object, you can simply multiply the current forward direction of the object by the rotation quaternion that you calculated. Here's an example code snippet:

// Get the current forward direction of the object
Vector3 currentForward = transform.forward;

// Calculate the new rotation by rotating the forward vector 60 degrees to the right
Quaternion newRotation = Quaternion.Euler(0f, 60f, 0f);

// Calculate the resulting forward direction by multiplying the current forward direction by the new rotation
Vector3 resultingForward = newRotation * currentForward;```
In this example, we first get the current forward direction of the object using transform.forward. We then calculate the new rotation quaternion using Quaternion.Euler, just as we did in the previous example. Finally, we calculate the resulting forward direction by multiplying the current forward direction by the new rotation quaternion using the * operator. Note that this operation does not actually rotate the object - it just calculates the resulting forward direction as if the object had been rotated.
blissful frost
#

i already asked chagpt and it answered my q

lean sail
solar jolt
#

Anyone got a solution for excluding all shaders from a build when firing UnityEditor.BuildPipeline.Build()?

shell scarab
#

How would I stop my camera from inverting when going upside-down? I'm setting the transform.forward to a vector pointing at another object to look at it, and I want to allow the camera to go upside-down.

This doesn't seem to happen with other objects when I use transform.forward = dir, so it leads me to believe it's something built into the camera component doing this.

lean sail
#

When you want it to be upside down, without rotation, where is the camera in relation to the player?

shell scarab
#

at a fixed point

plucky karma
#

Consider using Vector instead of transform. E.g. Vector3.forward.

#

(So as long as your camera doesn't rotate ๐Ÿ˜„ )

shell scarab
#

what do you mean? can you give me an example?

plucky karma
#

Vector3.forward returns a value of (0,0,1)

shell scarab
#

I don't think you understand what I'm doing.

#

I'm setting transform.forward to a direction vector.

lean sail
#

Are you changing only the x or z axis?

#

because y value would cause it to invert, x going 180 would be upside down

shell scarab
#

I'm literally doing transform.forward = direction;

shell scarab
#

when it goes back, Y gets set back to 0

#

I'm not doing this in my code and transform.forward doesn't do this on other objects, so it leads me to believe it's some built in thing in unity's camera component doing this to prevent cameras from going upside-down when rotating, which I want to allow.

plucky karma
#

When you say that your camera "inverted", what do you mean by that?

shell scarab
#

I'm not sure if inverted is the right word.

plucky karma
#

You're facing a gimbal lock.

shell scarab
#

well, why doesn't that happen with other objects!?

plucky karma
#

What does your direction value looks like?

lean sail
#

I dont think its a gimbal lock, i could be wrong but i think thats camera specific

#

Are you using a cinemachine camera?

shell scarab
#

no it's gimbal lock I'm a dumbass.

lean sail
#

๐Ÿค” howd u manage that

shell scarab
#

because that's what happens when you get gimbal lock and i thought it wasn't happening on other objects because I was like I TESTED IT but I literally had a script on that object that was setting the y value rotation to 0 every frame, so ofc it wouldn't change to 180