#💻┃code-beginner

1 messages · Page 37 of 1

chrome wasp
#

and then I drag in Gregg rb?

polar acorn
#

what

#

just drag the object into the variable you already made

chrome wasp
#

ohh the public Rigidbody rb;

rich adder
#

Rigidbody is the component, rbis the name you given it

chrome wasp
#

So I want to drag gregg into that?

rich adder
#

yes if it has a rigidbody

pastel talon
#

also, I tried this but it doesn't work

rich adder
chrome wasp
pastel talon
#

The trigger is working because it's doing what it supposed to, except for the particle part

polar acorn
chrome wasp
#

well you said to drag gregg to my variable

#

OHHHH

#

WAIT

rich adder
#

field in the inspector

chrome wasp
#

YEAHHHH

rich adder
#

we've said it like 5 times

chrome wasp
#

ikikikik I just realized

#

but I do not see it even with public thing

rich adder
#

probably because you have compiler errors

chrome wasp
#

I SEE IT

#

great ok new issue :/

#

i have heard this is what programming is like

warm sleet
#

Hello, im programing in unity and I dont know if its possible to make by code that when a missile hits an object, the object break into pieces, I mean, the block is still there but it has less space

pastel talon
warm sleet
#

An easy example are the bunkers from space invaders

queen adder
#

oof

#

im goin insane

chrome wasp
#

it still says rb is not assigned but now my gregg is just randomly moving diagonal

#

when I start the code

polar acorn
pastel talon
#

Swedish lol

polar acorn
rich adder
chrome wasp
#

I only have one script

#

WAIT

#

thats what I did wrong isnt it

pastel talon
chrome wasp
#

Because that script is for moving the character the collision needs its own script?

polar acorn
chrome wasp
#

oh idk

#

I only have one script tho

rich adder
#

why don't you start showing the current code

#

don't use screenshots and paste the link

pastel talon
polar acorn
#

but if whatever you did fixed it that was probably the case

rich adder
#

this moves it diagonal

pastel talon
#

thanls

#

thanks

chrome wasp
rich adder
#

you have to put back your old direction you had @chrome wasp

chrome wasp
#

with the variables?

polar acorn
rich adder
#

just replace transform.translate to rb.velocity

#

all you had to do

#

direction stayed the same

chrome wasp
#

ohhhhhhh

#

"The variable rb of Mover has not been assigned.
You probably need to assign the rb variable of the Mover script in the inspector"

#

So I assumer

#

I probably need to assign the rb variable of mover script

rich adder
#

bruh

polar acorn
chrome wasp
#

in the inspector?

rich adder
#

search inside the hierarchy t:Mover

warm sleet
chrome wasp
rich adder
warm sleet
#

If i need that the barrier breaks in a specific point, because the bullets wont hit always at the same place

gilded sinew
#

guys i could really use help, struggling with dictionary since morning and it doesnt work somehow

rich adder
chrome wasp
#

My boy Gregg has the component

gilded sinew
#

i created dictionary in scriptable object.
in game manager script i want to generate new dictionary with data in it

#

and when i want to print in textmeshpro data from that dictionary it doesnt work

#

could somebody help me out?

rich adder
#

clear the console and hit play

#

are you sure that error is still there

chrome wasp
#

yeah Gregg is the object I am trying to rb

chrome wasp
rich adder
polar acorn
chrome wasp
#

so do I need to assign the script rb?

#

cause Gregg has it

#

and I'm trying to rb Gregg

polar acorn
warm sleet
polar acorn
#

You have another Mover script that has no rb assigned

rich adder
chrome wasp
#

is it samplescene? I thought that was just like

#

a title

polar acorn
#

That's the scene

twin bolt
chrome wasp
#

cause it doesnt have an inspector or anything

polar acorn
#

Can you screenshot Gregg's entire inspector

chrome wasp
#

sure

#

like every drop down arrow expanded?

polar acorn
#

yes

#

(If they're expanded I can check multiple things at once @rich adder )

rich adder
#

yeah just realized

polar acorn
#

(we don't need them expanded for what I'm pretty sure we're both expecting but there could be a different problem)

chrome wasp
#

This will be several ss

rich adder
rich adder
chrome wasp
rich adder
chrome wasp
#

its in backwards order but yeah

polar acorn
#

You have two Movers

#

and one of them has no rigidbody

#

You probably don't want two

rich adder
#

computer never lies 😦

chrome wasp
#

uh ohhh

#

how do i get rid of of second one

rich adder
#

right click delete ?

chrome wasp
#

iyeyee

polar acorn
chrome wasp
#

got ti

#

ok the errors are gone

#

and the posistions are changing on the inspector

#

but i am not moving

rich adder
#

and did you change the variables to direction

chrome wasp
rich adder
chrome wasp
#

like do I get rid of movespeed and replace w3ith direction??

summer stump
#

Show your current code

Direction was passed into velocity if I read that rollercoaster correctly

chrome wasp
summer stump
#

Direction would be the vector giving you the direction of movement. MoveSpeed should be a float you multiply the vector by to modify speed

rich adder
#

in the inspector

#

might wanna crank that up

chrome wasp
#

ahhhhh

#

it says my movespeed is 25 in the inspector

rich adder
#

which Mover script did you remove..

chrome wasp
#

that one

#

but then I put gregg into the other one

rich adder
chrome wasp
#

I screenshot gregg in scene?

rich adder
#

ya

summer stump
#

Might wanna remove the deltaTime from your velocity movement
Do
float xValue = Input.GetAxis("Horizontal") * moveSpeed;

#

Same with zValue

chrome wasp
rich adder
#

I think Time.deltaTime is fine for consistent move speed

chrome wasp
#

o

rich adder
#

no?

summer stump
#

Velocity is meters per second, so it's already scaled by time. I thought you shouldn't do deltaTime with it

#

I dunno though

rich adder
#

could be

chrome wasp
#

should I try changing it?

#

ok i tried changing it

#

got this "Literal of type double cannot be implicitly converted to type 'float'; use an 'F' suffix to create a literal of this type"

#

changed it back

#

annd that is still there

polar acorn
rich adder
#

you can't write 0.3 you need 0.3f for example in a float field

chrome wasp
#

fixed it

#

ye

#

OK SO GOOD NEWS

#

he moves

#

only diagonally

#

i am stupid

#

i fixed it

#

IT WORKS

#

OMG THANK YOU SO MUCH GUYS

#

EEEEEEE

rich adder
chrome wasp
#

I am very sorry I put you through that lol

polar acorn
#

🥳

chrome wasp
#

BUT YES IT WORKS SO WELL!!!!

rich adder
#

hmmweird iirc time.delta time is fine on inputs but it was just to low of a value, I have to use * 10 when I do it on inputs to get consistent speed.
But I don't do it on the rigidbody itself

#

23 * 0.05 (how much is time.delta time again?) s about 1.15
@summer stump

summer stump
# chrome wasp BUT YES IT WORKS SO WELL!!!!

One thing to keep in mind that people sometimes dislike:
GetAxis has smoothing.
It will go from 1 to 0 to -1 smoothly, with the decimals between. This can make the player feel "floaty"

If you don't want that "on ice" feeling, use GetAxisRaw, which ONLY return -1, 0, 1 for the values. It snaps to them immediately

But that is for you to test and feel

chrome wasp
#

hmmmm I think I like the smoothing a bit more

#

but one more thing

#

Whenever I manage to flip myself I like float back down

#

its like there is gravity but it is SO SLOW

rich adder
#

you're overriding gravity

#

because of .velocity

#

you need to add .y to the direction

#

this is a code question how?

chrome wasp
#

what where do i put .y

rich adder
summer stump
chrome wasp
#

ohhhh

summer stump
#

Change that to rb.velocity.y

ruby python
#

!code

eternal falconBOT
chrome wasp
rich adder
#

project settings

#

or make a multiplier

chrome wasp
#

where in project settings?

#

after this I will give you peace

rich adder
#

its in Edit somewhere

chrome wasp
#

ohhh in physics

#

got it

ruby python
#

Okay, please don't shout at me but I'm very confused as to what's happening with this little script.

    [SerializeField] Transform referenceObject;
    [SerializeField] Transform solarPanels;

    // Update is called once per frame
    void Update()
    {
        transform.rotation = Quaternion.Euler(0, referenceObject.rotation.y, 0);
        solarPanels.rotation = Quaternion.Euler(referenceObject.rotation.x, 0, 0);
    }

I have an empty which is always pointing at the sun. I'm using that to grab the rotation values and applying them to my solar panel 'post' and the actual panels. I'm very confused, because the rotation on the post works great, but on the panels they don't move.

Does anyone know why when it's pretty much the exact same code please?

chrome wasp
#

ty

amber spruce
#

how do i increase the radius of the character controller

modest dust
short hazel
modest dust
#

^

short hazel
#

Quaternions store a rotation on 4 axes (x, y, z, w) with each value ranging from -1 to 1

rich adder
amber spruce
#

i tried this

characterController.radius += radiusIncreaseAmount;
ruby python
#

Yeah tbh I knew that about Quaternians. Was just very very confused as to why it worked for one, but not the other. lol.

amber spruce
#
public float radiusIncreaseAmount = 0.1f;
private CharacterController characterController;

and this for the variables

amber spruce
#

it doesnt work

rich adder
#

where do you assign character controller @amber spruce

#

and how you know it doesn't work

short hazel
amber spruce
ruby python
rich adder
short hazel
ruby python
#

No wait, my fault. lol.

#

Yeah sorry, brain is minced. lol.

amber spruce
rich adder
#

always use the inspector when possible

#

avoids these issues

open edge
#

Whats best way to learn basic scripts? Is it official Documentation? For example PauseGame standart scripts like stop time exit game or load level?

amber spruce
#
Error    CS0029    Cannot implicitly convert type 'UnityEngine.Vector3' to 'float'    Assembly-CSharp    C:\Users\vinny\My first game\Assets\movement\CrushObjects.cs    84    Active```
#

thats what i get

eternal needle
#

A radius is a single number

amber spruce
eternal needle
#

Multiplying a vector by a number gives you a vector, scaled by that number.

rich adder
amber spruce
#

how do i set my players radius to Vector3.one * 0.1

#

cause thats what i set the players scale to

#

and right now the scale and radius arent the same

rich adder
#

why Vector3.one ?

amber spruce
#

because thats how i get my scale to work how i want it

#

i dont really remember why i did Vector3.one lol

rich adder
#

you're trying to squeeze 3 numbers in 1

amber spruce
#

did that over a week ago and i ahve a terrible memory

#

it works for the scale

#
transform.localScale += Vector3.one * 0.1f;
rich adder
#

thats because scale is not a single number

#

its a vector3

#

and you return a vector3

amber spruce
#

so how would i increase my radius by the same amount

#

because just increasing it by .1 doesnt work

rich adder
#

thats the same as doing 1 * 0.1 3 times (0.1, 0.1, 0.1)

polar acorn
amber spruce
rich adder
amber spruce
amber spruce
#

i want the collider to be the same size as the model thing

rich adder
#

so use the scale magnitude of the object or something

#

hard to say idk what ur situation looks like

amber spruce
#

well if i set it to the exact scale then its wrong

rich adder
#

scale.magnitude * sumnumber

#

hard to do it by scale alone but you're not giving much to on 🤷‍♂️ lol

amber spruce
#

i think i got it its a little big but it should work

rich adder
#

oh you wanted it bigger

amber spruce
#

yeah my game is about eating all the objects to get bigger

#

you eat them by colliding with them

rich adder
#

gotcha

#

think I remember this a few days ago

amber spruce
#

although it seems to already increase it with the size so not sure why its not working right

#

i wonder if its because its a circle

#

should i be using like a box collider or smth

#

because when you get big enough it gets really hard to eat small objects

gray bough
#

Does anyone mind helping me getting a button on my scene to work? I have read a lot of tutorial articles and watched a lot of videos and I'm not sure why it's not working. I'm working in a 2D setting

silk night
#

Do you have

  • EventSystem in your scene?
  • Graphic Raycaster on your canvas?
gray bough
silk night
#

makes elements on the canvas clickable

amber spruce
ruby python
#

!code

eternal falconBOT
polar acorn
ruby python
#

Okay, well I'm losing the will to live. lol.

Sorry, I know this should be really simple stuff but I just seriously don't understand what's going on.

    [SerializeField] Transform referenceObject;
    [SerializeField] Transform solarPanels;

    // Update is called once per frame
    void Update()
    {
        transform.localRotation = Quaternion.Euler(0, referenceObject.eulerAngles.y, 0);
        solarPanels.rotation = Quaternion.Euler(referenceObject.eulerAngles.x + 90f, 0, 0);
    }

Everything is pretty much working as it should be except for the Z axis on the Solar Panel Rotation, it should stay at its local 0, but it just doesn't. I've tried setting the solarPanels to localrotation, but if I do that, then nothing works. The 'pole' object works perfectly though.

#

Actually, scratch that, sorry, the pole item isn't working, it doesn't rotate on the y as it should when set to local

silk night
#

you want the items to look at a reference object or have the same rotation as the reference?

wintry quarry
ruby python
#

Same rotation as the reference. The reference is using LookAt to look at the sun, the solar panels are split into two object, one that 'spins' around it's Y axis, and the actual panels that spin around their X axis.

wintry quarry
#

Also using isolated euler angles from a transform like that is usually not going to work well

ruby python
#

Trying to get these panels to always point at the sun object I have in the scene.

#

OH!!! I just figured it out. lol.

#
[SerializeField] Transform referenceObject;
    [SerializeField] Transform solarPanels;

    // Update is called once per frame
    void Update()
    {
        transform.localRotation = Quaternion.Euler(0f, referenceObject.localEulerAngles.y, 0f);
        solarPanels.localRotation = Quaternion.Euler(referenceObject.localEulerAngles.x + 90f, 0f, 0f);
    }

Needed to grab the localEulerAngles from the reference object.

amber spruce
#

when you get big enough the only way to colide with stuff is by the very bottom touching it which isnt very big of a area

rich adder
amber spruce
#

that doesnt work because now i just fall through the map

rich adder
amber spruce
#

and its still only that little bit that hits the ground

rich adder
#

oh so you don't want the capsule shape ?

amber spruce
#

no because it messes with collisions

rich adder
#

then don't use CC

amber spruce
#

dont i have to make a custom one for movement then

#

or no

#

does that deal with movement?

rich adder
#

do u want a box or sphere?

#

yes use a rigidbody with sphere / box w.e shape u want

amber spruce
#

ok thanks

rich adder
amber spruce
#

like its hard to actually collide with smaller objects

#

if your big enough it becomes impossible

rich adder
#

a box at the bottom or something

#

it wont sync up with cc tho

silk night
#

if you have the possiblity, make all objects you want to eat collider very high so it is easyily touched by the cylinder part

#

for your game you could even use 2d collision and just make the visuals 3d

fluid crane
#

Hello guys, anyone can help me with a question, i have a UI Image in my game and i want to make a glow effect behind it from a color that variate depending on the rarity.

What is the best practice to replicate that in unity?

Image as example attached.

amber spruce
silk night
#

not if you destroy them on touch

azure zenith
#

Is there a way to explode a throwable when it lands on the floor?

#

I am supposed to do it in a method with no parameters allowed

silk night
amber spruce
silk night
amber spruce
#

so i have trees and stuff

#

and houses

#

rocks etc

amber spruce
#

because i have tons of objects

silk night
#

depending on how detailed it needs to be just roughly estimate the shapes with cylinders, box colliders and so on

fluid crane
silk night
#

i think box colliders auto size to a mesh if you put it on them

silk night
azure zenith
amber spruce
silk night
amber spruce
#

yeah but i cant do that to all of them at once

#

i have to do it for each one

dreamy ingot
#

Is it possible to pass in a script to another script without using the scripts name as its variable type?
Instead of doing "public jumpController playerJumpController" is it possible to have a generic script type or something like that?
I'm trying to build a framework for the generation of magic spells modeled after D&D 5e's spells via scriptable objects where you can simply drag in a
procreated spell functionality in a provided script or create your own script to use for its mechanics.

silk night
polar acorn
uncut veldt
#

Hi im having a problem with null reference exceptions for some gameobjects that are reference in a list that are assigned in the inspector and it is only these object sand even if they arent in a list the same issue is happening the relevent code is ```cs private void RPMLightsMovement() //controlls which light should be on
{
rpm = controller.RPM;
float closest = GetRPMClosest(rpm);
RPMLightsDict[closest].On();
List<float> ramaingVals = new List<float>();
foreach (float val in RPMLightsVals)
{
if (val > closest)
{
ramaingVals.Add(val);
}
}
foreach (float val in ramaingVals)
{
RPMLightsDict[val].Off();
}
}

private void PopSliderVals(float mRPM) //uses maths to work out a value at which each light should be used and then adds that as a key and the game object as a value in a dictionary
{
float interval = (0 - mRPM) / (RPMLights.Count - 1);
for (int i = 0; i < RPMLights.Count; i++)
{
RPMLightsVals.Add(mRPM + (i * interval));
}
RPMLightsVals.Reverse();
for (int i = 0; i < RPMLights.Count; i++)
{
RPMLightsDict.Add(RPMLightsVals[i], RPMLights[i]);
}
}

Any help is apreciated
uncut veldt
# polar acorn What line is the error

line 5 RPMLightsDict[closest].On() and line 29 RPMLightsDict.Add(RPMLightsVals[i], RPMLights[i]) its whenever i access the gameobject or the script i have attatch to said gameobject to try and fix this error

languid spire
#

RPMLightsDict not initialised?

polar acorn
#

Try logging some values to see which one it is

uncut veldt
polar acorn
ivory bobcat
uncut veldt
polar acorn
#

Log some values, find out which is null

edgy prism
#

Hello I am having a bit of trouble with my coroutine so, when I have choices canContinue is false I want to be able to select my choices then continue with the first bit of code

while(story.canContinue)
        {
            var currentLine = story.Continue();
            AudioManager.i.PlaySfx(AudioId.UISelect);
            yield return TypeDialog(currentLine);
            yield return new WaitUntil(() => Input.GetKeyDown(KeyCode.Z) || Input.touchCount > 0);
        }

        if (story.currentChoices.Count != 0)
        {
            yield return choiceBox.ShowDialogChoices(story, onChoiceSelected);
        }
uncut veldt
polar acorn
ivory bobcat
polar acorn
ivory bobcat
#

I can't really debug for you because the project is in front of you and not me.

polar acorn
#

Either log the values or step through with the debugger to find out what is null

edgy prism
edgy prism
subtle veldt
#

Hey I've made a grappling hook in my game. So I can shoot it and it enables a SpringJoint2D between my player and the grapple head.
As you can see in the video it does really unnatural movements. It looks like the Spring tries to pull the player towards the right or the left of itself and not in the direction of the player.

uncut veldt
# polar acorn Before you attempt _any_ sort of debugging or problem solving, _find out what th...

so i have added this statement to debug Debug.Log(string.Concat("Light ", i, " reading ", RPMLights[i].gameObject.name)); which when i run it it shows that the light is there and the name is correct however after the first ittereation in the for loop the null reference error is thrown maybe the update function is called while the dict is getting populated so it cant find the light but if that is the case i didnt think update got called before start had finished

ivory bobcat
gilded sinew
#

@rich adder u have nice tutorials

polar acorn
#

Find the one that is blank, or the last one before an error occurs

#

and see which variable is null

ivory bobcat
gilded sinew
#

guys for some reason i cant fill my dictionary from loop. i tried lots of stuff. only if i add pair manually it worked. can somebody help me out why code above doesnt work? the line that i highlited code somehow doesnt reach it otherwise i would get pairs created in dictionary

ivory bobcat
#

Log to see if it has reached it.

gilded sinew
#

how to do that 🙂

rich adder
#

use Debug.Log

polar acorn
gilded sinew
#

oh right i forgot about that

#

ty guys

#

ill test it now

#

since morning trying to figure out why it doesnt work PB_shrug

ivory bobcat
#

The assumption was that it doesn't reach that line of code. Verify it.

gilded sinew
#

yes, trying now

#

yep it doesnt reach it. not getting any messages when i run it

ivory bobcat
#

So maybe tile game object is always null

gilded sinew
#

i guess that means that tileGameObject is = null somehow

#

yeah not sure how tho

ivory bobcat
#

Or none of these statements are ever processed.

uncut veldt
gilded sinew
#

no some are bcs i used log thingy above to check if loops is running and it did

gilded sinew
ivory bobcat
#

That wasn't what the line of code saw/thought/said.

gilded sinew
#

yep

rich adder
#

are you sure those are cells positions you're passing and not World Positions?

gilded sinew
#

hmmm good point

#

but i tried for 0 0 0 and tile on that spot still didnt get result i wanted (when i open it some stuff should happen confirming that tile has data assigned to it via dictionary)

gilded sinew
#

i have a tile on map with coordinates 0 0 0 and even on that one dictionary hasnt created pair (data for it for that position)

#

i think that no mater what cell position i am passing at least that one should work since world position and cell position match there or i am thinking wrong

rich adder
#

what you see in the inspector is not neceserraily the 00 for tilemap

#

tilemap i think starts from bottom left of the screen

#

grid has its own system

gilded sinew
#

hmm idk i used TMP in canvas to display coordinates on clicked tile and 0 0 0 is in center of my tilemap

rich adder
#

how do you know u hit the tilemap ?

gilded sinew
#

using ray that detects tile i am touching

#

then extracting coordinates of that tile

cobalt granite
#

If I have multiple weapons how do I keep track of which kind I have equipped so I know which animations to play?

wintry quarry
#

currentlyEquippedWeapon

cobalt granite
#

right but should I just be like constantly checking for what object I have equipped or is there a more efficient way to do that?

rich adder
# gilded sinew using ray that detects tile i am touching

are you using world to cell ?
Yellow is mouse click, Pink is WorldToCell yellow pos

 Gizmos.color = Color.yellow;
        Gizmos.DrawSphere(mouseClick, 0.23f);
        Gizmos.color = Color.magenta;
        Gizmos.DrawSphere(grid.WorldToCell(mouseClick), 0.13f);```
gilded sinew
#

this is returning null somehow

#

tested with debug.log and that is the problem that line. just dont know how to fix it

rich adder
# gilded sinew

I think this only gets the GameObject that a tile might have spawned

gilded sinew
#

pepe_hmm ok go on

rich adder
#

not 100% never used that function

gilded sinew
#

ok how to get game object from that position?

rich adder
#

I think its because tiles , technically arent gameobject

#

just a data representation of something there with a sprite

gilded sinew
#

hmm but when u make them on map they show as separate game objects

rich adder
#

i thought it was for this

gilded sinew
#

i see

rich adder
#

doc mentions only Scriptable Tiles 🤷‍♂️ i guess it has to do with that

gilded sinew
#

aight ty bud. trying different aproach now if that doesnt work then i have to think of something else.

#

good thing is we know what line is issue

rich adder
#

maybe try getting the tile and do .gameObject ?

#

the doc doesn't clarify

rich adder
gilded sinew
#

i want to extract tile tag

#

thats the main and only purpose

#

tile tag/ game object tag

rich adder
#

the tile has no tag tho

#

not sure what u mean

gilded sinew
#

then i need game object tag

#

lemi show you

#

no wait

rich adder
#

so this isn't a tilemap object

chrome wasp
#

dammit im back again

gilded sinew
#

i meant

#

bellow

rich adder
#

I get it

chrome wasp
gilded sinew
#

tag Water

rich adder
#

but this isn't a Tile

#

this is a gameobject

#

nothing to do with tilemap

gilded sinew
#

then why does code above not work yikes

rich adder
gilded sinew
#

shouldnt c# show error then

rich adder
#

bruh its literally null

#

hence ur if statement not hitting

#

there is no error if u dont try to use something null

gilded sinew
#

okay okay

#

i see

rich adder
#

just get it how you would get any other gameobject

gilded sinew
#

how do i fix that to get god damn tag bro crycat

#

i cant think anymore been struggling with this since morning

rich adder
#

how do you want to get object? with a raycast ?

gilded sinew
#

yeah

rich adder
#

collider.gameObject.tag

gilded sinew
#

jesus i think i know what u mean

chrome wasp
#

my gravity is weird and idk how to fix it

gilded sinew
#

navarone u are boss

chrome wasp
#

its like no matter what I put it at I still fall slow

chrome wasp
rich adder
rich adder
gilded sinew
gilded sinew
chrome wasp
#

I was editing it in project settings but I googled it and put in some code, I'll send the code

rich adder
#

what happen to the :OhNo emoji..

chrome wasp
#

Last two lines

rich adder
#

this is hella wrong

#

yValue

#

this is supposed to be your rigidbody.velocity.y

#

or a multiplied version f it

chrome wasp
#

I changed it cause jump

#

oh wait

#

i just realized

#

changing it back

rich adder
#

also gravity x ?

chrome wasp
#

now i cannot jump

rich adder
#

forgot how to do jump with .velocity but you have to add onto the current value

#

then pass that inside Y

chrome wasp
#

what where when am i adding onto w

#

"So firstly he’s already got a Y velocity that you are just overwriting 🙂 Hence the weirdness… You could add something to his velocity: rigidbody.velocity = rigidbody.velocity + Vector3.up * 2; Or you are probably better adding a force: rigidbody.AddForce(0,10,0); Bear in mind that rigidbodies…" found that in google

#

rigidbody.velocity = rigidbody.velocity + Vector3.up * 2;

#

Can I use that

rich adder
#

or is that unity answer

chrome wasp
#

its a unity answer

#
rich adder
#

i usually use addforce but u can give it a try, since addforce wont work with .vel

chrome wasp
#

error

#

"'Component' does not contain a definition for 'velocity' and no accessible extension method 'velocity' accepting a first argument of type 'Component' could be found (are you missing a using directive or an assembly reference?)"

#

so my code

#

doesnt know what velocity is?

heady nimbus
#

your reference is rb based on your original post

rich adder
#

show the line u changed

chrome wasp
#

I added the if statement

heady nimbus
#

you want rb.velocity += Vector3.up * 2

chrome wasp
#

wowahahhh

chrome wasp
#

my guy just kinda

#

flew

rich adder
#

because ur constantly adding

#

to itself

#

think you need to do in some sort of button press

chrome wasp
#

oh right

#

for the jump button press

chrome wasp
#

with the grey

heady nimbus
#

surround it with the backtick `

chrome wasp
#

(Input.GetButtonDown ("Jump"))

#

so I need that

chrome wasp
heady nimbus
#

Yes, and you'll also need a ground check so that you can't keep pressing jump while in the air. That part is a little bit more complicated

chrome wasp
#

that was going to be my next quetion but ima take this one step at a time

upper spire
#

how can i determine the material of the face a physics.checksphere hit?

chrome wasp
#

if (Input.GetButtonDown ("Jump")) { rb.velocity += Vector3.up * 2; }

#

I have added that code

#

and there are no errors but I cannot jump

upper spire
chrome wasp
#

would the code I wrote out work in theory? Like did I use an if statement right?

chrome wasp
heady nimbus
#

I don't think it's the velocity assignment. Your button press looks wrong, but I'm not sure if you're doing a controller input or something that I"m not used to?

#

Mine usually looks like Input.GetKeyDown(KeyCode.Space)

upper spire
# chrome wasp where do i plonk it in

something like

rb.AddForce(Vector3.up * 2, ForceMode.Impulse);

you can also try swap out your getbuttondown for a getkey then use keycode.space or something just to test the input detection

rich adder
chrome wasp
#

hm ok

heady nimbus
#

Yea, AddForce and velocity are different ways to move

chrome wasp
chrome wasp
upper spire
chrome wasp
#

oh okay

silver zenith
#

you could consider adding in a debug.log to see if the button is even registering

upper spire
#

or input.getkeydown if you only want it to enable for 1 frame after clicking

heady nimbus
#

Well as far as I know, GetButton is usually for controllers

silver zenith
#

Debug.log ("some message")

#

add it in the if statement

#

and then test jump to see if message prints

#

in console

rich adder
#

try this

chrome wasp
#

I THINK IT WORKS

gilded sinew
#

TYYYYYYYYYYY

chrome wasp
#

why is it that sometimes if i go high enough up I just fall through my plane?

gilded sinew
#

this fixed my problem

rich adder
#

nice

gilded sinew
#

ty bro, legit 8 hours sturggling with this stuff

rich adder
gilded sinew
acoustic arch
#

i get an error

gilded sinew
#

dont want to experiment and lose another 8 hours

acoustic arch
#

for the 1st code

chrome wasp
#

Okay final issue

#

I can just double jump infinite times

gilded sinew
#

oh wait that was meant for lilith lol

#

@chrome wasp i guess its our lucky day

chrome wasp
#

lol

rich adder
heady nimbus
#

Suggestions on the best way to have an enemy ai detect the edge of a platform, reverse direction, collide with an opposite wall and reverse again? (Basically just like 3-4 different collision checks?)

rich adder
#

eg Physics.Raycast or Physics.Spherecasst etc.

rich adder
#

maybe raycasts

heady nimbus
chrome wasp
#

and how do I...

#

box/ray/sphere cast

rich adder
chrome wasp
#

k

heady nimbus
# rich adder eg Physics.Raycast or Physics.Spherecasst etc.

So I've got a raycast that I've set to originate from the front edge and point down, which seems to be handling the "edge of platform" scenario, but I'm having trouble getting the raycast to flip sides when the sprite flips. I don't know if I need to set up like 4 different ray casts to detect in every direction basically?

heady nimbus
# chrome wasp box/ray/sphere cast

Yea, this is definitely something you should do some google research on. Raycasts are super easy once you understand them and hugely useful. Worth learning for any project

rich adder
heady nimbus
#

Well I mean right now the sprite is just the default square that I reverse the localScale.x for

rich adder
#

topdown or side view?

heady nimbus
#

Side

rich adder
#

I tend to rotate object on the Y axis

chrome wasp
#

I'm gonna go learn c# then come back to this

#

or at least the basics

#

get an understanding of it

heady nimbus
mild mortar
#

I'm trying to learn how to use the new input system and so I was changing a bit of my code.

What's the ideal method for moving the player character?
I was using transform.Translate originally but the movement is odd since it just stops completely when I let go of a button, instead of slowing down in a more realistic way, but then somewhere I think someone mentioned to try using AddForce. But now my character just falls over on the spot when I press a key instead.

heady nimbus
acoustic arch
#

hey how can i make 2 gameobjects the exact same, like to have the hotbar slots in my inventory change with the ones on the screen?

#

and what would it be called btw

heady nimbus
#

This is for 2D obviously, but just check the appropriate freeze rotations and it shouldn't fall over

mild mortar
#

!code

eternal falconBOT
mild mortar
#
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{

    private PlayerInput playerInput;
    private InputAction jumpAction;
    private Rigidbody rb;

    // Speed of the player
    public float speed = 5.0f; 
    // Jump force of the player
    public float jumpPower = 5.0f;
    [SerializeField] Transform groundCheck;
    [SerializeField] LayerMask ground;

    // Start is called before the first frame update
    void Awake()
    {
        playerInput = GetComponent<PlayerInput>();
        jumpAction = playerInput.actions["Jump"];
        jumpAction.ReadValue<float>();
        rb = GetComponent<Rigidbody>();

    }

    // Update is called once per frame
    void Update()
    {
        // Get the horizontal and vertical axis values.
        float horizontal = playerInput.actions["Movement"].ReadValue<Vector2>().x;
        float vertical = playerInput.actions["Movement"].ReadValue<Vector2>().y;

        // Move the character based on the axis values.
        rb.AddForce(Vector3.forward * vertical * speed * Time.deltaTime);
        rb.AddForce(Vector3.right * horizontal * speed * Time.deltaTime);

        // Jump if the player is grounded and the jump button is pressed.
        if (jumpAction.triggered && Grounded())
        {
            rb.AddForce(Vector3.up * jumpPower, ForceMode.Impulse);
        }
    }

    bool Grounded()
    {
        return Physics.CheckSphere(groundCheck.position, .1f, ground);
    }
}
heady nimbus
#

Modify your force values, 5 might not be enough if that's what you were using with translate? They're 2 very different systems

rich adder
#

Dont mulitply rigidbody with Time.delta time

mild mortar
# heady nimbus Modify your force values, 5 might not be enough if that's what you were using wi...

Sure I'll give that a try

Just to check then, is AddForce actually the generally recommended way for having movement on a character?

And the other thing I was meaning to ask is, is locking the rotation not a proper fix for this? As I figured it is gonna cause a problem for me when I want the character to turn while running if holding W & D for instance

I'm brand new to Unity so sorry if it's a stupid questions

heady nimbus
#

Oh yup, I missed that. You don't want delta time when adding force or velocity

silk night
#

It generally behaves a bit different and you will have different problems with each of them that you need to solve, but its not a question about what should you do, but more about what you want to do

eternal needle
#

MovePosition on a kinematic rb is also the same as just moving the transform position. It just does extra stuff like give it a velocity during the move

heady nimbus
mild mortar
#

Yeah it's definitely more useful physics wise as I just want to make a sort of platformer at the moment with large objects etc that swing and knock you off etc

eternal needle
#

You can still rotate it by locking all axis. That locking only stops it from rotating due to physics

#

But it can also cause somewhat weird interactions. You can see this by locking position and throwing an object at it

#

Instead of locking all rotations, you could constantly apply torque to get it towards the rotation you want

wintry harbor
#

Someone please help me. In my scene, I have an array of players gathered by using FindObjectsWithTag("Player"). I want each player in my scene to have a unique number (1-8). I've tried accomplishing this via lists and dictionaries, but whenever I do, I get the error "index is out of bounds". Is there a better way to go about doing this?

tl;dr I want to create a list of player objects each with a unique number attached to them (1-8).

formal escarp
#

I have a question about coding. I was told that the code is different for 2D projects and 3D. But how much different? Even the movement? Is there any place where i can read about code for 2D? (2D Similar to Enter the Gungeon, Dont starve or games like this?)

eternal needle
mild mortar
#

Hmm I see

It's a lot to wrap my head around. I tried using the "Starter Assets - Third Person Character Controller" asset recently, that's actually exactly what I want as the character moves, rotates and such in a proper way.

My goal is to get to that point atm, but I want to try to do it myself and learn rather then import theirs

heady nimbus
polar acorn
summer stump
summer stump
#

That is one way for sure

heady nimbus
#

Oops... Lol

formal escarp
#

Is just that? A physics thing? do you guys think 2D is easier than 3D? (Again .I mean games like Cult of the lamb, dont starve, etc) the only thing i can think of is when i used to use GameMaker or similar for 2D games and i would just put invisible blocks for not getting out of bounds.

rich adder
#

I find 2D harder because the assets are harder to work without an artist

wintry harbor
# summer stump Yep

I have something like that. I have the number of players in the scene in an integer variable, and it displays in the log the number of players in the scene. But it doesn't keep track of each individual player, just the number of players.

rich adder
#

the code is exactly the same mostly @formal escarp

formal escarp
#

Do you guys have any link i can read talking about how to start stuff like a bullet hell? i hope i am not being annoying.

rich adder
#

the logic all that is the same

heady nimbus
#

I mean both are suitable for different things. It depends on what you want to do. Some ideas will be easier in 2D some harder

formal escarp
formal escarp
#

btw i failed my exam today. I spent all week coding but before we gave that to teacher we had to take a exam and i got 8/15. and you needed 9/15. so teacher wont even look at my prototype of game. 💀

silk night
#

If you really do not care if its 2 or 3d, a 2d game saves you a lot of trouble in different scenarios

rich adder
#

3D is just easier to work with esp if you're not particularly good at drawing

heady nimbus
formal escarp
timber tide
#

sculpt tool actually pretty easy to use in blender, but for the life of me I can't draw 2D

summer stump
heady nimbus
formal escarp
rich adder
#

3D more or less has 2 style

#

sylized/Lowpoly and Realisitic

silk night
heady nimbus
rich adder
#

thats because the textures

#

but those are easier to change

formal escarp
#

btw im a bit sad i failed the exam man. i was 1 question away from going thru.

timber tide
#

wake up call to study more

silk night
rich adder
#

yeah I mean art direction is everything, but just saying 3D is easier to blend together than 2D

eternal sage
#

can anyone help me with an issue im having in unity?

formal escarp
heady nimbus
#

Yea, like I said i"m not an artist, but I'd much rather work on 2D assets then 3d. Lol

heady nimbus
formal escarp
#

but at least now i know some of the basics. how to move, raycast and how it works, how to make jump and platafforms move, etc.

formal escarp
eternal sage
formal escarp
heady nimbus
formal escarp
#

anyways. thanks guys. ill go and try to find anything that i can read that it tells me how to start bullet hell 2D.

rich adder
gilded sinew
#

i have small issue cant figure out why. Using function to convert cell to world position and one coordinate is converting properly but other isnt. z is converting good but x isnt.

rich adder
#

how can we help to something you cannot explain @eternal sage

heady nimbus
gilded sinew
#

method that is converting cell to world position. not sure how one is converting properly but other isnt

rich adder
formal escarp
polar acorn
gilded sinew
formal escarp
#

and how to move i guess. i am not even sure if the code of moving on 3D and 2D is the same but im guessing no because of the Vectors as previously said.

heady nimbus
polar acorn
eternal sage
formal escarp
gilded sinew
#

yes bud @polar acorn and its x minimum is -14 cell position and world position of that tile is -14.something and when converting i am getting -11.something or -12.something

heady nimbus
polar acorn
swift crag
#

I have a plain-old C# class that I want to be able to log an error from. I want to log something that helps me find the offending class (it's always going to be serialized on a component somewhere).

Any idea how I can do that? Obviously I can't just log this, 'cos this thing isn't a unity object.

#

Perhaps I should just hand it a reference to the component it's a part of.

heady nimbus
polar acorn
polar acorn
# gilded sinew

And it's populated, right? You've got tiles in all the positions you're expecting to get?

gilded sinew
#

yeah its populated but u did point me out one thing that could be issue for something else, tho it still doesnt explain why vallue is not matching for one axis but is for other

tame mist
#

hello, I'm struggling to figure out why my code is having an issue passing a gameObject reference from one script to the other.

The currentCar gameObject is initially set as the cars driver door but I assign it as the actual parent car gameObject with the transform.parent.parent... code.

the log statement shows it's the instantiated prefab gameObject, but for some reason my code is having an issue passing it to another script that needs the reference.

// CarRadialMenuManager Script
private void SendCarToMechanic()
{
    currentCar.GetComponent<DriveCar>().ExitVehicle();

    currentCar = currentCar.gameObject.transform.parent.parent.parent.parent.gameObject;

    Debug.Log("currentCar = " + currentCar);

    // this line below is giving the NullReferenceException
    mechanicController.AddCarToList(currentCar);
}

//MechanicController script
public void AddCarToList(GameObject car)
{
    carList.Add(car);
}
polar acorn
gilded sinew
tame mist
polar acorn
tame mist
gilded sinew
#

after 10 hours i completely fixed my problems

#

ty all that helped

#

gn

#

apsolute gigachad

#

@ navarone

rich adder
cobalt granite
#

https://gdl.space/hequxatoqa.cs

So I have this script that uses animation key events to run most of the methods and I'm planning on adding a bunch of other spells other than fireball, but I want to know if I'm doing something like super wrong and it'll bite me in the ass later on

rich adder
#

they can even be scriptable objects that have their own methods

#

just swap out the asset and run its Fire method

cobalt granite
#

Yeah I was going to make a simple GUI that with button presses 1 2 and 3 will select which spell it is using, but I just wanted to make sure it seemed like scalable I guess. Like I've never really gone too big with games so idk if adding like even 30 different kinds of spells would be a ton

rich adder
#

with SO it wouldn't be

#

with enum 30 is a lot

cobalt granite
#

SO?

rich adder
#

ScriptableObject

#

its a class as an asset

#

more or less

#

they just goated to create variations of something

cobalt granite
#

so having a list of a ton of spell strings wouldn't be good?

#

I'll look into all of that

rich adder
#

I mean you could do some type of dictionary look up or something

#

wouldn't be so horrible

#

kinda flimsy , not a big fan of strings unless I make const but then you're making a big ass const class

cobalt granite
#
 private void spellSelect() 
    {
        if (Input.GetButtonDown("Fire1") && firing == false && selectedWeapon.Equals("Staff")) 
        {
            Debug.Log("firing-true");
            firing = true;
            anim.SetBool("Firing", true);
            //Everyspell will have their own if statement
            if (selectedSpell.Equals("Fireball")) 
            {
                Debug.Log("FireBall");
                anim.SetTrigger("Fireball");
            }
        }
    }

Like in this the last if statement, each one will have it's own spell its checking and the selectedSpell will be chosen from like clicking a button on a GUI

#

and then I have a big state animator tree and each transition to each spell has a unique trigger

rich adder
#

imagine how big you have to make the if statement to check all possibilities?

#

even with a switch

cobalt granite
#

Yeah thats true, it would be like 30 different if statements

sour fulcrum
#

Whats the cleanest way to cast a Vector3 to Vector3Int? dealing with it often enough to where I’d rather not constantly do (int)x, (int)y,(int)z

cobalt granite
#

well I plan on having them in like classes, like fire ice electric, so I guess it could check what class its in then what spell exactly to shorten the amount of checks

rich adder
#

my caster doesnt care what its casting, the cast takescare of it

#

it justcares about cooling times and speed

sour fulcrum
sour fulcrum
cobalt granite
#

so your saying have it be like a method called, castSpell(currentSpell) and then that currentSpell class would have all the script to it

cobalt granite
rich adder
#

your spell would probably have a child class to its specific type of spell

sour fulcrum
#

If you did it via ScriptableObjects you could just store a

string animationString

Then do animator.SetTrigger(currentSpell.animationString)

rich adder
#

whatever is mechanically the same would have the same SO/Class for behavior

#

only data type changes

cobalt granite
#

Okay, well thank you for all the info, hopefully it all turns out okay

rich adder
#

eg all weapons/rifles have the same thing going on mechanically. Fire projectile, only thing that changes is the rate of shooting etc.

cobalt granite
#

Ohh so have all the common data to each spell on the castSpell method and everything else in its seperate thing?

rich adder
#

the commonality would be the method that fires this and behaves according to the data

#

instead of CastingFire, you just Cast(fire)

#

then cast method knows what values to use from fire and how to handle the rest

cobalt granite
#

Okay, yeah that makes sense

#

thank you

rich adder
tame mist
#

hello, I have cars that will become children of lifts in a mechanics garage. When the lift goes up by animation, the car is supposed to move up with it. but it doesn't seem to work when the cars rigidbody is attached to it.

I tried different combinations of setting the rigidbody of the car to isKinematic = true, detectCollisions = false, and useGravity = false
but with those options it seems like the car will raise up just a little bit, but not all the way up with the lift.
the only thing that has worked so far is completely removing the rigidbody on the car at runtime before it goes on the lift and then when it comes back down off the lift I put a rigidbody back on the car and give reference to the few places in scripts that need it.

the problem i'm having with that approach is that it seems to mess up the way the vehicle drives. like for example when turning it tilts way too much, yet all the same settings seem to be applied to what controls the car mechanics.
I really don't want to completely remove the rigidbody from the car as it seems to give me problems, but I don't know why the other approaches I took didn't work.
any ideas?

acoustic arch
#

currently the items can go in the inventories list in the script

#

but it cant ever show up in the games inventory

acoustic arch
#

if i add an item, itll create another slot at the bottom

teal viper
#

Make sure you don't run any of the car driving logic, when it's in the lift.

#

If it's using wheel colliders, might want to disable them too(I don't remember if they can be disabled though)

teal viper
#

In fact, the past thing is irrelevant, so only 2.

acoustic arch
#

now i get the error from line 47

#

which i think is an improvement

#

GameObject obj = itemContainer;
var itemIcon = obj.transform.Find("icon").GetComponent<Image>();

teal viper
#

What error, and what's on line 47 now?

acoustic arch
#

null

#

instance not found

swift crag
#

we have no idea what line 47 is

#

you posted several files and you've made changes since posting them

swift crag
#

you are not getting an error from line 47

#

that's impossible

#

GameObject obj = itemContainer;

itemContainer is a field, and reading a field cannot cause a NRE

teal viper
#

Probably the old code

acoustic arch
#

NullReferenceException: Object reference not set to an instance of an object
InventoryManager.ListItems () (at Assets/Scripts/Item Scripts/InventoryManager.cs:47)
MenuOpener.Update () (at Assets/Scripts/UI/MenuOpener.cs:21)

swift crag
#

ensure that you've saved the file

tame mist
swift crag
#

this would be consistent with deleting line 47 and then saving before adding GameObject obj = itemContainer; back in

acoustic arch
swift crag
#

The line of code literally can't cause an exception. It's an instance method accessing a field on its own object.

acoustic arch
#

yeah weird

swift crag
#

I presume itemContainer is a prefab. Grabbing the Image from the prefab would not make much sense.

acoustic arch
#

im slow

#

var itemIcon = obj.transform.Find("icon").GetComponent<Image>();

#

is the issue

#

the line is different on mine than hatebin and i said hatebins not mine

teal viper
teal viper
#

And still the same way of dealing with it.

swift crag
#

I would strongly suggest making a component for the "item container"

#

so that you can instead have

#
ItemContainer itemContainerPrefab;
teal viper
#

Also, yeah, what Fen mentioned about it being a prefab

swift crag
#

that component can have a field that references the container's Image.

#
public class ItemContainer : MonoBehaviour {
  public Image icon;
}
#

e.g.

#

I almost never store things as a GameObject

acoustic arch
#

like what i did here

#

public class Item : MonoBehaviour
{
public ItemData ItemData;
}

swift crag
#

the important idea is that it'll let you access its components without having to go digging around for them

#

using Find and GetComponent is very brittle

acoustic arch
#

yeah

swift crag
#

if you rearrange the prefab a little, it can suddenly stop working

acoustic arch
swift crag
#

I've been doing some messy UI work today, but I never had problems with components randomly not being found

swift crag
acoustic arch
#

alrightr

acoustic arch
swift crag
#

the point is that you'll be able to do this

#
var holder = Instantiate(itemContainerPrefab);
holder.icon.sprite = whatever;
#

instead of

#
var holder = Instantiate(itemContainerPrefab);
holder.transform.Find("icon").GetComponent<Image>().sprite = whatever;
acoustic arch
#

do i put this script on my items prefabs?

swift crag
acoustic arch
swift crag
#

not as a GameObject

acoustic arch
#

yeah

acoustic arch
swift crag
#

i don't understand what you mean

acoustic arch
#

just ignore that

#

i was just restating what you said

#

i got another error tho

#

ArgumentException: The Object you want to instantiate is null. UnityEngine.Object.Instantiate[T] (T original) (at <c2d036c16ca64e0eb93703a3b13e733a>:0) InventoryManager.ListItems () (at Assets/Scripts/Item Scripts/InventoryManager.cs:48) MenuOpener.Update () (at Assets/Scripts/UI/MenuOpener.cs:21)

swift crag
#

well, assign it

#

you didn't assign anything to the field

swift crag
acoustic arch
swift crag
#

I presume you passed itemContainer to it

#

That means itemContainer is null.

#

Assign the prefab to it.

acoustic arch
#

public class ItemContainer : MonoBehaviour {
public Image icon;
}

#

this image

swift crag
#

I said nothing about an Image.

swift crag
swift crag
tame mist
teal viper
acoustic arch
#

im being very dumb

swift crag
#

to reiterate:

  • your "item container" prefab should now have an ItemContainer component on it
  • your InventoryManager component should have a reference to this prefab. The reference should be in a field of type ItemContainer
upper spire
swift crag
#

This field should replace the GameObject field you originally had.

#

the itemContainer field should now be an ItemContainer.

acoustic arch
swift crag
#

I don't know what that means

acoustic arch
#

the component ItemContainer is the script

swift crag
#

I only use "script" to refer to the actual source code.

#

The thing you see in the inspector is a component.

teal viper
acoustic arch
swift crag
#

You can reference a prefab by any component on the prefab's root object

swift crag
#

When you instantiate it, you'll get a whole new object

#

(it doesn't just duplicate the component or something)

#
public ItemContainer itemContainerPrefab;

void Start() {
  ItemContainer myContainer = Instantiate(itemContainerPrefab);
  myContainer.icon.sprite = ...
}
acoustic arch
#

i had

#

var holder = Instantiate(itemPrefab);

swift crag
#

That will work, as long as itemPrefab's type is ItemContainer.

#

Is that the case?

acoustic arch
#

yes

#

ItemContainer myContainer = Instantiate(itemPrefab);

        myContainer.icon.sprite = item.icon;
swift crag
#

okay, good. and did you drag the prefab into the itemPrefab field in the inspector of the inventory manager?

acoustic arch
#

oh it wasnt public

#

i was confused for a second

#

or seralized

#

neither

swift crag
#

that will prevent it from showing up, yeah

acoustic arch
#

sorry you have to deal with me im trying to progress learning 💀

#

well

#

now the error is in line 50

#

NullReferenceException: Object reference not set to an instance of an object
InventoryManager.ListItems () (at Assets/Scripts/Item Scripts/InventoryManager.cs:50)
MenuOpener.Update () (at Assets/Scripts/UI/MenuOpener.cs:21)

swift crag
#

okay, so what's on line 50?

acoustic arch
#

myContainer.icon.sprite = item.icon;

#

is it from the myContainer or item.icon?

#

like what isnt being set

swift crag
#

use the thread, please

acoustic arch
#

thread?

acoustic arch
#

mb

mossy arrow
swift crag
#

use Debug.Log statements to check if your code is running at all

mossy arrow
#

where do i use it?

#

in what code?

summer stump
#

Also in GameOver

#

Does the LogicManager have the Logic tag?

frozen mantle
#

i know there's a way to simplify this but this is just to catch all edge cases for my enemy AI, lol
if((playerInSightRange && !playerInAttackRange && playerInLineOfSight) || aggroTime <= chaseTime && (!playerInAttackRange || playerInSightRange && playerInAttackRange && !playerInLineOfSight))

frozen mantle
#

ugh

upper spire
#

how can i get the movement speed of a non rigidbody object?

swift crag
#

you would have to measure it over time

#

game objects don't have a velocity

sour fulcrum
elfin eagle
#

I have a question so I have a game object in scene one, and in scene two there is a prefab of that game object. My character has a script attached to it that the game object in scene 2 needs to access but it cant since it is from originally from scene 1 (Im using do not destroy on load). I need help to find a way that the gameobject in scene 2 can access it when the player enters the scene

sour fulcrum
#

I might understand it wrong since I don't have the full context but maybe worth seperating your bools into

hasValidTarget => playerInSightRange && playerInAttackRange && playerInLineOfSight
readyToAttack => aggroTime && chaseTime
hasValidAttack => readyToAttack && hasValidTarget

mossy arrow
summer stump
sour fulcrum
#

also just a random guys opinion but playerInSightRange might be better named playerInRangeOfSight so it's consistent with playerInLineOfSight

mossy arrow
summer stump
#

Looks like you called that object Logic Manager

#

Tags go on objects

mossy arrow
#

last one?

summer stump
#

That's it, and you got it

mossy arrow
#

so uhm

#

does it work?

summer stump
mossy arrow
#

nope it does not work

summer stump
#

Did you do the debugs to check the rest?

mossy arrow
#

so what do i do rn

#

how do i do that?

mossy arrow
#

it makes things not hard for me

summer stump
#

Read the docs, it has examples

ashen ferry
#

how could I place points on a sphere but each must be atleast x distance away from any other

summer stump
mossy arrow
summer stump
#

It literally has example code

mossy arrow
summer stump
#

Debug.Log("words");

mossy arrow
#

so i write Debug.Log() or Debug.Log("words");

#

btw it has to look like this

summer stump
# mossy arrow so i write Debug.Log() or Debug.Log("words");

Bro, look at the link. Take a minute to think about it. Take a minute to think about how you can use it. If you need to, look up a tutorial on it.
You are trying to determine which functions are running, and using Debug logs will help with that, because you will only see the words in the console when the code runs

#

13 is MORE than old enough to figure this out

mossy arrow
mossy arrow
summer stump
summer stump
mossy arrow
#

so know i will ask 1 more time at the end of what script do i put Debug.Log() or Debug.Log("words");?

mossy arrow
#

THEN WHAT!...

summer stump
#

You add text in the method call. Text that makes sense and is descriptive

mossy arrow
#

"You add text in the method call."????????

summer stump
# mossy arrow bro im so lost

You may want to stop doing unity and do a beginner c# course then...

Do you know what a method is?
The things with these: ()

#

You call a method when you write that somewhere.

#

Except when you are declaring the method (when you see something like public void in front)

#

Debug.Log("any kind of thing I want to write here") calls a method that writes that text into your console

#

If you write Debug.Log("my oncollisionenter method successfully ran") inside your Oncollisionenter method, wouldn't that help determine things?

mossy arrow
#

so it talks to me when i use Debug.Log

#

ok so do i use Debug.Log

#

like this

rich adder
#

its underlined red

#

you're missing something

mossy arrow
rich adder
#

Log is a function

mossy arrow
#

WAIT

#

this???

rich adder
#

it takes parameters

wintry quarry
#

Mouse over it

rich adder
#

read the errors