#💻┃code-beginner

1 messages · Page 814 of 1

subtle mulch
#

yeah ik, lol

inland ruin
#

Hi everyone, I'm a noob at unity, so I'm asking for help on how to transform .bland in .unity3d? I use the mod in the 7days, where I can use the models, but I don't understand how to convert these files normally(

sour fulcrum
#

we cant help with mods, sorry

inland ruin
sour fulcrum
#

idk homie your the one who brought up the mod side of it, not me 😛

#

Unity uses .obj and .fbx files, you'll have to find a blender discord or other support online for exporting

keen dew
#

Converting things to the unity3d format is only done for modding

pallid holly
#

Guys, I wrote this code to make my player (a cube) move but it passes through walls. Can you give me some advice?

teal viper
pallid holly
pallid holly
#

Oh, I understand, and what can I use in the project (code) to make my player move? I'm new and just learning.

#

sorry for bad english i'm italian

teal viper
#

!learn

radiant voidBOT
teal viper
#

Or follow some tutorials online.

pallid holly
#

So I think I'll learn the basics thanks to !learn. Do you think it helps a lot?

teal viper
#

Yes

pallid holly
pallid holly
teal viper
#

Also, if you want to grow as a developer I recommend improving your English. It's indispensable for a developer.

pallid holly
pallid holly
#

you say that with !learn I can learn everything about the basics and then start doing a first mini project

teal viper
#

Reading the manual and the api docs can also be very helpful.

radiant voidBOT
#
<:error:1413114584763596884> Command not found

There's no command called manual.

teal viper
#

!docs

radiant voidBOT
pallid holly
#

yes I think these days I'll read everything and start with the Unity Learn Pathways

#

Do you have any advice on where to start?

teal viper
pallid holly
#

yes I saw that there are many and they last 12 weeks so I was wondering which one I should start with

errant breach
#

Hello ! Im trying to play a death particle for enemies.
My particle is a prefab, given as a gameObject to the enemy. When he dies, the particle is Instanciated but as a child.
Because the enemy is destroyed at the same time, so is the child.

How can i make the particle is not instantiated as a child ? I tried looking on the web but it doesnt work.

  • public ParticleSystem TestParticle;
  • Instantiate(TestParticle, transform.position, transform.rotation);

Thanks for the help !

sour fulcrum
#

set the particles parent to null

errant breach
#

Nice ! So there is a way ! But how can i do it please ? Because my prefab does not have any code 😅

sour fulcrum
#

Instansiate returns the thing it's creating

#

you can reference the particle via that

pallid holly
#

!learn

radiant voidBOT
errant breach
# sour fulcrum you can reference the particle via that

Is see, thank you ! Im trying to read the documentation but i really dont understand how it work... Do you know a tutorial that explain this easily ? Because ive watched a lot of instantiate's tutorial but i've never seen such thing. Or if you know how to achieve this in my scenario, i would be very grateful !

subtle mulch
#

using transform is NOT how you make a player controller

pallid holly
#

yes bro but I wanted to ask for some advice then honestly I think I will do all the Unity courses so I can learn better if I already know something I will repeat it

#

thx very much ❤️

subtle mulch
#

there is a component called Character Controller btw

#

you should use that

pallid holly
#

bro I told you I'm new now I'm going to follow all the courses so I think I'll learn thank you very much for everything

subtle mulch
#

yeah i was just saying what you should look for

pallid holly
#

yes yes I understood it I really appreciate it a lot

nocturne hawk
#

wanting to make a reader/engine in unity to get data from .josn's for dynamic game character building for a 2D game, how can I find a 1:1 tutor?

subtle mulch
#

and they are free

subtle mulch
nocturne hawk
sour fulcrum
#

you will find a 1:1 tutor with money

nocturne hawk
#

ye that was the idea

sour fulcrum
#

and a place on the internet that offers those services

subtle mulch
#

yep, that's why you should go for YT tutorials

sour fulcrum
#

there's no paid type stuff on this server

naive pawn
nocturne hawk
subtle mulch
#

well, you explained in your message, read a json file, also, no one will help someone that doesn't know what they need

nocturne hawk
#

I knoe what I want I just have 0.1/10 coding experience

subtle mulch
#

and that's why you can search in youtube

teal viper
#

That's the point where you go and learn coding.

nocturne hawk
#

can I shoot an explanation here and mabye some1 can tell me what to look for?

subtle mulch
#

ye

teal viper
#

Or you can pay someone on upwork to code it for you.

midnight plover
sour fulcrum
#

paying for a tutor is totally valid too, just not something offered here

nocturne hawk
subtle mulch
#

fiverr or upwork prob

naive pawn
#

don't have any ngl lol

subtle mulch
#

or even

#

!collab

radiant voidBOT
# subtle mulch !collab

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

naive pawn
subtle mulch
#

tho they normally are pretty expensive+

sour fulcrum
#

1:1 education is inherently expensive, theres no getting around that

midnight plover
#

I think we can conclude the topic then, as long as you dont need any help with code yet to not clutter up this channel

naive pawn
nocturne hawk
# subtle mulch ye

character hitbox and collision box info on different states, keybind triggers, attack functions etc inside .jsons, I got examples, { "on_state": { "idle":[ { "binding_boxes": [ {"hurtbox":{"x":100,"y":160,"offset_x":0,"offset_y":0},"collisionbox":{"x":110,"y":165,"offset_x":0,"offset_y":5}} ] } ], "dash":[ { "binding_boxes": [ {"hurtbox":{"x":60,"y":80,"offset_x":0,"offset_y":0},"collisionbox":{"x":110,"y":165,"offset_x":0,"offset_y":5}} ] } ] } } For providing the hitbox on different states for example

subtle mulch
#

yeah

#

make a script that reads it

subtle mulch
#

converts to some struct

nocturne hawk
subtle mulch
#

and then process the struct

nocturne hawk
#

i Know 0

subtle mulch
nocturne hawk
#

🙁

subtle mulch
#

and YT tutorials

nocturne hawk
#

yes C#

naive pawn
#

tip: google is a very powerful tool

subtle mulch
#

yep

naive pawn
#

googling "c# read json" would get you a pretty good chunk of the way there

nocturne hawk
#

I use chat gpt but I want to know what the code does not just copy and paste

subtle mulch
#

bruh, just don't pls

naive pawn
#

tip: stop using ai tools, they'll include some weird misleading stuff with confidence lmao

pine elm
#

guys, I'm trying to get a specific shader look for my game (im the game designer, not developer)
is it true that I can get a shader with pure code, without using shader graphs in unity ? I want a specific anime look

nocturne hawk
#

thx for the help

midnight plover
sour fulcrum
#

all shaders are pure code yes, shader graph is just a way to visually create them

subtle mulch
#

and you don't do shaders in C#

pine elm
#

interesting, would Úou recommend using AI for it ? or AI isn't good enough yet for unity shader codes ?

subtle mulch
#

thesere are prob the places you are looking for

sour fulcrum
#

most people here wouldnt recomend ai for anything

subtle mulch
naive pawn
#

@nocturne hawk
if you aren't familiar with c#/unity in general, i'd suggest learning that on its own first, eg working with the editor to familiarize yourself with the concepts, etc
doing that, and then adding the json-defined values, would be easier, rather than learning the entire workflow at once

sour fulcrum
#

shaders are written in HLSL, lot of stuff online for you to read or watch

pine elm
subtle mulch
#

they are their own languages

pine elm
#

its hsls

naive pawn
#

close

pine elm
#

hlsl

sour fulcrum
#

halal snack language

pine elm
#

lmao

#

so i need a guy that can write in that halal language

#

damn

subtle mulch
#

or just learn it

pine elm
#

could my dev learn it fast ?

#

if he knows c sharp

subtle mulch
#

maybe?

sour fulcrum
#

not neccasarily

subtle mulch
#

the logic is nearly the same

#

but you don't have classes

sour fulcrum
#

the logic being the same isnt really the problem

#

its a very different kind of work

subtle mulch
#

it's more similar to C tbh

sour fulcrum
#

its maths on maths

pine elm
#

so in theory, he could use AI, and then try and modify / fix some element of it to get the rendering objective

naive pawn
#

faster than starting from absolute 0 i guess, since they'd already know some core concepts like how strings work or matching braces

sour fulcrum
#

Honestly i'd just suggest looking for a third party asset to work from/with

#

paid or unpaid

naive pawn
pine elm
#

I do intend on simply using toon shader assets from the store

naive pawn
#

you still need to know what you're working with

pine elm
#

but I would have prefered being able to make it from scratch to get more customization possibilities

subtle mulch
#

maybe this?

pine elm
#

well I had 2 or 3 in mind

#

I never heard of that one

#

looks cool though

#

i had the unity toon shader in mind for instance

pine elm
subtle mulch
#

nope

#

not even close XD

pine elm
#

it's made a lot of progress recently, mainly through claude

#

lol, I guess it depends on the environment yea

subtle mulch
#

those percentages are very inflated

#

and if they use it, they just use it for autocomplete / comments

pine elm
#

right

subtle mulch
#

or repetitive tasks

naive pawn
#

also, look what it's doing to the ecosystem lmao

subtle mulch
#

and to RAM / SSD prices

pine elm
#

yea thats indeed a real drawback

naive pawn
pine elm
#

but surely, we will find a way to create new source of unlimited energy thanks to AI right, right ?

subtle mulch
#

no

#

at the current stage, nope

#

not even close

midnight plover
#

At least we will keep on having this topic in the coding channels daily now...

naive pawn
pine elm
#

i guess my follow up question doesnt have a place here too then : also from my understanding, shaders are one thing, but texture is as important as shaders

#

😄

naive pawn
#

this is the coding channel

subtle mulch
#

textures are simple tbh

pine elm
#

can't you code texture ?

naive pawn
subtle mulch
#

no

#

you cannot "code" textures

#

you can generate textures

#

via code

naive pawn
subtle mulch
#

but not "code" them

sour fulcrum
#

the difference your trying to make is nonexistent

naive pawn
#

i mean, everything on the computer is code. but you aren't gonna be asking us how pixels physically work

pine elm
#

you also generate shaders, you don't code them right

naive pawn
#

you can write shaders

#

this.. is not the proper channel for discussing shaders either

pine elm
#

ok I will go there then, thanks for the answers guys though 🙂 really appreciate it

#

if we have some coding questions I'll be back

naive pawn
#

just because everything relates to code, or everything can be done by code, does not mean this channel is appropriate to ask in

imagine asking a fullstack developer how to make generative/procedural art lol. they might be able to do it, but that's not their professional expertise.

pine elm
#

ahah yea I was messing around x)

#

have a good day folks

real thunder
#

I messing with homing algorithms and I ve encounered... math
so through using the augmented proportional navigation homing I am getting a centripetal force
other basic algorythms I use just rotate transform like that

      target_rotation = Quaternion.LookRotation(to_target_prognosed - transform.position);
      transform.rotation = Quaternion.RotateTowards(transform.rotation, target_rotation, angularVelocity * Time.fixedDeltaTime);

question is: can anyone help me figure out a way to transform a centripetal force into rotation inbetween quaternions or transform rotation inbetween quaternions into a centripetal force?
going the second route I got

      float force = rb.mass * R * angular_velocity  * angular_velocity;

where R meant to be a radius I should somehow get from two quaternions... tricky math rabbithole it seems
any useful ideas?

#

I want to have those algorithms behave on same terms so I could compare

naive pawn
#

centripetal force in concept is a linear force, not rotational - what exactly is the behavior you're trying to get?

real thunder
#

yeah this is annoying
there is a "augmented proportional navigation" algorithms used for homing missles sicne WWII given what I read is true
and the formula (I understand inputs but I have no clue why it considered optimal) have a centripetal force as an output

#

not a torque or a quaternion rotation....

naive pawn
#

if you're trying to get it to rotate how it does physically, like a ball on a string or tidal locking, you would just have the object rotate to face the pivot

naive pawn
#

i guess centripetal force encodes the curvature, assuming you already know the thrust/velocity?

real thunder
#

that formula even got a magic number in it

real thunder
#

sadly I suck at geometry and asking here if anyone can speed up my struggle

real thunder
naive pawn
# real thunder also I don't understand what that means

torque affects the rotation of the object, while centripetal force affects the trajectory

so if you want a certain trajectory, you would figure out the arc, then the centripetal force required to get that arc, i guess? and then from there you can calculate the gimbaling or control surface movement to get that centripetal force

naive pawn
real thunder
#

in that case, I would need to get a Quaternion change out of radius

#

jut to clarify
I got two homing algorithms (still finishing writing the second one, ugh, but it should work)
one is straightforward where I just calculate mean intercept position and get a LookAt quaternion and RotateTowards
another meant to be more effective for evasing targets but formula only gives me centripetal force
I want to make them use one same method of rotating the missle

sage mirage
#

Hey, guys! I have a question. How I am supposed to get a reference to my emission of particle system?

#

I have used the Particle System itself but it doesn't allow me to get reference to it

#

you know what I mean the property of the particle

#

I am getting this

naive pawn
#

seems like you're trying to use it in an invalid context, given that it's complaining that the type isn't found

#

show some more context there

sage mirage
#

What I want to do is to Lerp from one value of my emission rate to another

#

but I cant get reference to my emission

naive pawn
sage mirage
#

maybe I need emission module?

#

as well

naive pawn
# sage mirage

the error here is unrelated to how the particle system is set up, it is a compiler error

#

you likely have some syntax errors above that make this access not correctly parsable

sage mirage
#

No the problem is that I have to access the property I think otherwise I wont get reference to it

#

its like getting out the override/effect of post processing

#

you cant change directly from a post processing volume any effect you want, you first have to extract it lets say

real thunder
naive pawn
#

(i'm using physics symbols/terms here out of familiarity/habit, if you need clarification on anything just ask)

#

also if you're using an rb, you could also assign to angular velocity

#

hm, this doesn't encode direction.

#

i'm thinking in 2d thinkies

real thunder
#

well the direction is to the intercept point

naive pawn
#

are you in 2d or 3d?

real thunder
#

it's 3d but the plane of interception is easy to find

naive pawn
#

ah, alright, that should work i think

real thunder
#

yeah now given that and one post I found "Rotation quaternion to angular velocity" I got all the pieces

#

time to cobble them

stuck cedar
#

How to use unity

timber tide
#

¯_(ツ)_/¯

polar acorn
radiant voidBOT
errant breach
#

Hey everyone, im trying to make so my enemies have both a colliderBox (to get damaged) and a DetectionBox (given as an invisible square, child of the enemy).
The issue is that using "OnTriggerEnter" make the enemy take a damage even if the player only hit the DetectionBox. How can i make so that the two boxes are different ? Thanks for those who can help !

polar acorn
#

Multiple colliders on one object basically become the same collider (which you might see referred to as a "composite collider").

You'll need to put one collider on a child object, then check which object you hit to determine if you should deal damage.

brazen pumice
#

I'm trying to get a mario kart style ghost system, using a gameobject that adds my players location to a list, then creates a copy and passes the list of positions over. However, I keep getting a Specified Cast is not Valid error

subtle mulch
brazen pumice
#

yeah that's what I thought lmao

subtle mulch
#

send your code

brazen pumice
#
{

    List<Vector2> positions;

    public Transform player;
    public GameObject copy;
    public bool isRecording;

    private GameObject clone;

    void Start()
    {
        positions = new List<Vector2>();
    }

    void FixedUpdate()
    {
        Record();
    }

    void Record()
    {
        positions.Insert(0, player.position);
    }


    public void createClone(Vector2 spawnPos)
    {
        clone = Instantiate(copy);
        clone.GetComponent<dummyMovement>().positions = positions;
        positions.Clear();
    }
}```
subtle mulch
#

and the exact line where it fails

brazen pumice
#

it's the clone.GetComponent<dummyMovement>().positions = positions;

subtle mulch
#

what is dummyMovement?

brazen pumice
#
{
    public List<Vector2> positions;

    void Update()
    {
        Replay();
    }

    void Replay()
    {
        for (int i = 0; i < positions.Count; i++)
        {
            transform.position = positions[i];
        }
    }

    public void setPositions(List<Vector2> pos)
    {
        positions = pos;
    }
}```
subtle mulch
#

bruh, why did you name it with a lowercase at the start...

brazen pumice
#

i didn't name it lmao, collaborative game jam

subtle mulch
#

pls rename it

#

it's so confusing

#

now

#

show me the prefab you are passing as clone

#

and also what the error says precisely

brazen pumice
twin pivot
subtle mulch
#

that's what i was thing too yeah

#

it might interfere

#

tho it would be very strange

brazen pumice
#

no change, unfortunately

twin pivot
subtle mulch
#

clone.GetComponent<dummyMovement>().positions = positions;

#

he said it before

silk night
twin pivot
#

it has no errors in the editor?

subtle mulch
#

he showed it in the screenshot

silk night
#

the only cast in that process is done on the dummyMovement generic

#

so if it can't cast to it theres something smelly going on with it

subtle mulch
#

also @brazen pumice
GameObject clone = Instantiate(copy, spawnPos, Quaternion.identity);

clone.GetComponent<dummyMovement>().positions = new List<Vector2>(positions);

#

try this

silk night
#

btw to make this a bit easier

public dummyMovement clonePrefab;
[...]

var clone = Instantiate(clonePrefab); <-- clone is automatically of type dummyMovement
subtle mulch
silk night
subtle mulch
#

oh cool

silk night
#

it just returns the component instead of the gameobject when you do it like this

silk night
subtle mulch
#

he is trying to set one in that script

#

not get it

twin pivot
#

worth trying still

subtle mulch
#

nah

brazen pumice
#

and I sorted out the name haha

subtle mulch
#

np

polar acorn
real thunder
#

assuming I copypaste code from a system where Vector3.Cross(a,b) is ruled by right hand rule into unity where left hand rule is working I should just add negative sign to it? Am I getting it right?

naive pawn
#

depends on what you're using it for

real thunder
#

oh no, it's complicated

naive pawn
#

["first time?" gif]

#

if you're using it for display, where you'd need the result to point in the same direction, you'd negate it
if you're using it for other calculations that would be based on the coordinate system, you might not need to

brazen pumice
#

one of my fixedupdates is going faster than the other lmao

naive pawn
#

either it's being called by something it shouldn't, or you're reading the wrong thing

night raptor
wintry quarry
brazen pumice
#

becaused i did something wrong lmao

real thunder
#

sigh, this meant to be the homing code and fiddling with Vector3.Cross didn't help
originally this is from right hand coordinate system thingie
homing works.... the other way around
the projectile is pretty effective at flying away from the target
what have I even done wrong
if you have a clue what's wrong with that please tell

public float max_accel;
    public float N = 3;
    void PurePN()
    {
        Vector3 to_target = target.position - transform.position;
        Vector3 closing_velocity = targetRb.linearVelocity - rb.linearVelocity;
        float to_target_distance = to_target.magnitude;

        Vector3 angular_velocity_of_los = Vector3.Cross(to_target, closing_velocity) / (to_target_distance * to_target_distance);

        float missle_velocity = rb.linearVelocity.magnitude;
        Vector3 force;
        if(missle_velocity > 0)
        {
            Vector3 linear_velocity_normalized = rb.linearVelocity / missle_velocity;
            Vector3 force_direction = Vector3.Cross(linear_velocity_normalized, angular_velocity_of_los);
            Debug.DrawRay(transform.position, force_direction * 100, Color.red);
            force = N * missle_velocity * force_direction;
        }
        else
        {
            force = Vector3.zero;
            Debug.LogWarning("");
            rb.linearVelocity = transform.forward * speed;
            return;
        }
        float force_magnitude = force.magnitude;
        if (force_magnitude > max_accel)
        {
            force = force * (max_accel / force_magnitude);
        }
        rb.AddForce(force, ForceMode.Acceleration);
    }
#

I would not be surprised if it didn't work

#

but it works backwards

#

nevermind, replacing Vector3.Cross with - Vector3.Cross only at second calculation worked

#

if I negate both it it doesn't work

#

I don't understand but okay

naive pawn
#

Vector3 linear_velocity_normalized = rb.linearVelocity / missle_velocity;
.normalized exists btw

real thunder
#

I know... I wonder if it's to save on calculations?

naive pawn
#

i guess, if this is a hot codepath

real thunder
#

I just basically copypasted python code as is

naive pawn
#

the python api mightve not had a .normalized method...

real thunder
#

the author used a library with this method

#

however he used it sparingly

naive pawn
#

probably your idea is correct then

#

especially if this is a lib where performance matters a bit more

#

can't really imagine all the vectors in my head but if i had to guess, it's probably that it needs to be negated, but when you negated both it just ended up at the same value (since one of them depends on the other)

real thunder
#

well the code is "for educational purposes or as a starting point for more complex simulations"
probably went for best he could

#

I tried to copypaste it double checking triple checking so

#

either original code not working

#

or the issue is elsewhere

#

or I got sloppy ofc

#

homing is a rabbithole apparently

timber tide
#

I just use rotatetowards and call it a day

real thunder
#

even if you use rotatetowards, what method do you use to predict target's future position?
what extra heading on top of that?

timber tide
#

why ya need a future position

real thunder
#

to intercept

timber tide
#

but if you do then grab the current transform value, dupe it, then translate it in the forward direction a few meters

real thunder
#

yeah you also need to account the time it takes to fly and at that point target would be even further

timber tide
#

translate the matrix towards some velocity value of the target transform

#

then rotate towards that

real thunder
#

I mean

timber tide
#

or if you want to use transforms, dupe the transform, move it, then destroy the gameobject at end of the frame

real thunder
#

it's annoying to predict the position taking into account missle speed

#

and travel time

timber tide
#

i mean that's how rigidbody's most basic speculation works

#

just predict where it's at using the velocity then sweep towards that direction

real thunder
#

I copypasted that without looking into it much

static bool GetInterceptDirection(Vector3 origin, Vector3 targetPosition, float missileSpeed, Vector3 targetVelocity, out Vector3 result)
    {

        var los = origin - targetPosition;
        var distance = los.magnitude;
        var alpha = Vector3.Angle(los, targetVelocity) * Mathf.Deg2Rad;
        var vt = targetVelocity.magnitude;
        var vRatio = vt / missileSpeed;

        //solve the triangle, using cossine law
        if (SolveQuadratic(1 - (vRatio * vRatio), 2 * vRatio * distance * Mathf.Cos(alpha), -distance * distance, out var root1, out var root2) == 0)
        {
            result = Vector3.zero;
            return false;   //no intercept solution possible!
        }

        var interceptVectorMagnitude = Mathf.Max(root1, root2);
        var time = interceptVectorMagnitude / missileSpeed;
        var estimatedPos = targetPosition + targetVelocity * time;
        result = (estimatedPos - origin).normalized;

        return true;
    }
#

and there is also option to add extra heading by several degrees just in case

#

...anyway this is way less efficient to hit a dodger and most efficient to hit a standing target

#

well, or one which just moves in a particular direction

icy grove
#

Hey everyone, I was trying to follow the Unity Essentials pathway and during the Programming Essentials I ran into kind of a stoppage because of the input system. I was following along and this is basically the script they gave me (except the jump part that I added).
How could I make use of the input system to make this type of simple movement? Because I tried to follow the tutorial in #🖱️┃input-system but my controls were messed up (basically, A and D go back and foward, W and S go left and right), could I get some help with this?

    public float speed = 5.0f;
    public float rotationSpeed = 120.0f;
    public float jumpForce = 5.0f;
    private Rigidbody rb; 
    private void Start()
    {
        //normal start
    }

    void FixedUpdate() 
    {
        Vector2 moveInput = Vector2.zero;

        if (Keyboard.current.wKey.isPressed || Keyboard.current.upArrowKey.isPressed)   moveInput.y = 1f;
        if (Keyboard.current.sKey.isPressed || Keyboard.current.downArrowKey.isPressed) moveInput.y = -1f;

        if (Keyboard.current.aKey.isPressed || Keyboard.current.leftArrowKey.isPressed) moveInput.x = -1f;
        if (Keyboard.current.dKey.isPressed || Keyboard.current.rightArrowKey.isPressed)moveInput.x = 1f;

        // Move in facing direction 
        Vector3 movement = transform.forward * moveInput.y * speed * Time.fixedDeltaTime;
        rb.MovePosition(rb.position + movement);

        // Y-axis rotation (invert when going backwards)
        float turnDirection = moveInput.x;
        if (moveInput.y < 0)
            turnDirection = -turnDirection;

        float turn = turnDirection * rotationSpeed * Time.fixedDeltaTime;
        Quaternion turnRotation = Quaternion.Euler(0f, turn, 0f);
        rb.MoveRotation(rb.rotation * turnRotation);
        
        //Added by me to add jump 
        if (Keyboard.current.spaceKey.isPressed)
        {
            rb.AddForce(Vector3.up * jumpForce, ForceMode.VelocityChange);
        }
    }
}
timber tide
#

So what's the problem

naive pawn
#

do some debugging, see where the issue starts - is it wrong from moveInput, or from movement/turnDirection?

icy grove
#

Hum I said it up there, but maybe it was confusing. How can I implement the player movement with the Input System?
The script I provided works fine, I just wanted to understand the Input System properly

timber tide
#

Oh right, A/D is mixed up I see. Reading comprehension

naive pawn
icy grove
#

Ok so I now see that I messed up my explanation, sorry about that. The word limit made me mess it up a bit.
That script I provided up there works fine, it just simply does not make use of the Input System, it's using the Keyboard.current.wKey.isPressed.
This is the simple script that DOES use the Input System:

{
   private Rigidbody rb;
   private float movementX;
   private float movementY;
   public float speed = 1;
 
   void Start()
   {
       rb = GetComponent<Rigidbody>();
   }
 
   private void OnMove(InputValue movementValue)
   {
       Vector2 movementVector = movementValue.Get<Vector2>();
       movementX = movementVector.x;
       movementY = movementVector.y;
   }
  
   void FixedUpdate()
   {
       Vector3 movement = new Vector3(movementX, 0.0f, movementY);
       rb.AddForce(movement * speed);
   }
}```
And in this one, A/D goes back and foward, W/S goes left and right
#

I wanted to know why that is happening and also, how can use the Input System to add jumping to my player controller

naive pawn
#

check if the composite binding for the Move action is set up correctly

timber tide
#

Kinda confused on what type of game composition this is. You have top-down movement it seems but also a jump button

naive pawn
#

doesn't third person with fixed camera basically also have this control scheme

icy grove
timber tide
#

oh it's 3D right, sorry too much 2D for me today

icy grove
#

These are my input actions. It's the default one

naive pawn
timber tide
#
Vector3 movement = transform.forward * moveInput.y * speed * Time.fixedDeltaTime;
rb.MovePosition(rb.position + movement);

Should just comment out your code and make sure forward at least works with y

naive pawn
real thunder
#

silly question but what if your camera is tilted

#

or something like that

#

misaligned

naive pawn
#

that code does not use the camera

icy grove
real thunder
#

the code does not use the camera but if camera is 90 degrees turned
forward backwards becomes left and right

#

well, it's not the problem I see

naive pawn
#

i was thinking it would be distinguished by the 'facing' direction of the player, but i guess that actually could be plausible if it's just the default capsule/cube

icy grove
#

So, I have the camera attached to the player. BUT the player is indeed turned 90 degrees in the positve axis

#

So this could actually be the cause?

naive pawn
polar acorn
# icy grove

If you need it to be visually rotated, I would recommend making the visuals a child object of the actual "Player" object and keep that object's rotation at 0,0,0. Then you can rotate the visuals to align with what unity expects "forward" to be

timber tide
#

I'm confused what's being asked here besides the jump button. Are controls reversed? Then it's probably the z of the transform is rotated

icy grove
#

Then this prompts another question from me. If I don't set the rotation like it is at the moment, the player starts facing in the wrong direction.
Is there a way to rotate the player so that it faces the correct direction and won't mess up the movement system?

naive pawn
#

take the rotation/directions of the object into account when applying forces

#

eg, using transform.forward/transform.right like you were in the other snippet

timber tide
#

Keep the motor of the character at the top, but visuals as the child if the model isn't imported correctly

icy grove
timber tide
#

regardless, always keep visuals child to the motor/controller

icy grove
naive pawn
#

exactly the same as it did before

#

changing input system only changes how you receive input

icy grove
#

Not sure I follow, if I use the Input System, like so:

   {
       Vector2 movementVector = movementValue.Get<Vector2>();
       movementX = movementVector.x;
       movementY = movementVector.y;
   }
  
   void FixedUpdate()
   {
       Vector3 movement = new Vector3(movementX, 0.0f, movementY);
       rb.AddForce(movement * speed);
   } ```
then if my rotation is messed up, it will mess up the movementX and movementY variables right?
naive pawn
#

no, movementX is just if you pressed A or D

#

that's all it is

timber tide
#

movement x would be in global here

#

so no matter the rotation you'll always move on the global x axis

naive pawn
#

(and that's because of the usage, not because of how you receive the input)

icy grove
#

Ok, I might be missing something here in respect to how the Input System works.
Just to see if I get it, by adding a Player Input component it makes it so that whenever I perform one of the mapped actions in my Input Actions it will send a message that can be caught, in this case, with the OnMove function in my PlayerController script?

#

So, if I create an action called Jump, it will send a message that can be captured with an OnJump function?

naive pawn
#

yes

timber tide
#

That's one way you can use it, yeah

icy grove
#

Ok, I guess that makes sense. Although I don't understand why movementVector.y will give me the input of A/D, because in Unity, the Y axis is the vertical one?

naive pawn
#

it doesn't

#

have you actually checked/verified that?

#

the issue before was your character being rotated on Y, so local x/z didn't align with global x/z
you expected your character to move relative to local x/z, but physics works on global coords

icy grove
#

AH, here, only movementX is actually getting any type of input then?

naive pawn
#

no

#

i'm not sure where you're getting these conclusions

icy grove
#

Sorry if these seem like dumb questions, just very new to Unity in general

naive pawn
#

your input is fine

#

you weren't using the result properly

icy grove
#

So if I wanted to keep that rotation I had initially, I would just need to add a minus to movementX and movementY?

naive pawn
#

no

#

that would work as a (honestly horrible) bandaid fix if your character was rotated 180°, but it's not

#

you would use the character's forward direction like you were in the working snippet

#

i said this 15 minutes ago

icy grove
#

Ah so, I could do for the movement, transform.foward * movementY?

naive pawn
#

yes

icy grove
#

Sorry if I'm just sounding dumb atm, but I just can't wrap my head around the X/Y/Z coordinates here

naive pawn
#

which part exactly? the global coordinates thing?

icy grove
#

Why is it that the movement in Y goes back/forward?

naive pawn
#

the x/y from input is unrelated to the x/y/z of the world

icy grove
#

AH

#

Ok I get it now, x/y from input is like in a normal 2D graph, with positive Y going forward and negative Y going backwards

#

And then I need to translate this into the global coordinates of unity

naive pawn
#

the x/y from input just tells you how the input is actuated. joysticks and mice work in 2d, WASD was designed for 2d, so they just have x/y

the unity world is 3d, so x/y/z, with Y being up

if you need to map the input onto the world horizontal plane, you use the input Y as the world Z

icy grove
#

Ok I think I understand very broadly how this will work and I can work with this now

#

Thank you very much for the patience and the explanations

brazen river
#

Hi

#

Hi guys

naive pawn
brazen river
#

il2cpp

#

Hi

naive pawn
#

please don't say just hello in chat

fickle plume
#

@brazen river To follow up the warning that got cut short. There's no talk about hacking or cracking games here.

icy grove
naive pawn
brazen river
#

.ok sorry 😐😞

icy grove
#

Because I have my movement script in the parent, here called Player. Should I put the Player inside a new Parent which takes the script?

naive pawn
#

that's what mao is saying, yeah

naive pawn
#

i don't really do 3d so i don't have firsthand experience with setting this stuff up

icy grove
#

And the camera, should it be attached to the new Parent or stay like it is?

naive pawn
#

the new parent

brazen river
#

Hey guys what game are you making?

#

Reply pls

icy grove
polar acorn
fickle plume
icy grove
timber tide
#

ya just need to rotate your visual so it faces the direction of your motor/controller's z+ direction

icy grove
#

Yeah, that part is not hard, what I mean is that now my visual is not moving alongside my parent

naive pawn
#

is it actually in the parent?

icy grove
#

So, if I press W, my camera follows my parent, but the visual just stays behind

naive pawn
#

show the heirarchy

icy grove
naive pawn
#

have you tried removing the rigidbody from the Player object

icy grove
#

Yeah ok that was it, I was trying to do it but I forgot it was a prefab so I had to alter the prefab first

#

Thank you

naive pawn
#

you don't have to do that

#

you can modify the instance and then apply the changes to the prefab

icy grove
#

I couldn't remove the component on the instance

naive pawn
#

weird, you should be able to..

icy grove
#

Ok weird you indeed can, I probably just did not see the option there

final gazelle
#

Heya all. Sorry to waste your time with a simple question, but I'm creating a simple "escape room" game/app that I can use with some students of mine. I learned today that I can play simple audio sources using buttons, so I've been doing minimal code.

Ran intro a problem though. Previously, I saw a YouTube video on how to make menu buttons to change scenes, and felt like I understood it, but today is a different day and I don't seem to understand still. Anyone mind helping me?

My code is as simple as this:

using UnityEngine.SceneManagement;

public class GameMenu : MonoBehaviour
{

    [SerializeField] private string gameScene1;
    [SerializeField] private string gameScene2;
    [SerializeField] private string MainMenuScene;

    public void Play()
    {
        SceneManager.LoadScene(gameScene1);
        SceneManager.LoadScene(gameScene2);
        SceneManager.LoadScene(MainMenuScene);
    }

    public void Quit()
    {
        Application.Quit();
    }
}```

I've made a "MainMenu" object with the script attached. I'm referring to this object on the buttons necessary and have assigned the function "GameMenu.Play", but how do I actually choose which scene is loaded on button click? I feel like I've missed something elementary, but I can't pinpoint. Sorry for the long question to something I have a feeling is very banal.
wintry quarry
#

how do I actually choose which scene is loaded on button click?
You would need to pass a different scene name into Load Scene for each button

#

You could do this e.g. by making a function like this:

public void Play(string sceneName) {
  SceneManager.LoadScene(sceneName);
}``` And then you can set the scene name in the inspector when you assign the function to the button on click
final gazelle
#

And you answered my question before even seein it 🙂

#

Thank you very much, PraetorBlue. I think that fully answers my question and should give me something to experiment with until it works out.

naive pawn
#

also sidenote i'd recommend Eflatun's SceneReferences package, it makes it easier to manage specifying scenes to load ime

final gazelle
#

I'll check it out - thanks!

brave robin
#

One annoying thing I found with [RuntimeInitializeLoadType.AfterSceneLoad] and SceneManagement, is that if I try to access a loaded scene it will fail, saying its not loaded. I have to add a one frame delay for it to work. So AfterSceneLoad doesn't seem to actually trigger after scene load, as not everything is done with loading.

#

Or it might not like that I have 2 scenes loading at the start. A main scene with logic that is always needed, and a level scene with that level's assets. My attempt to set the main scene as active will fail, with an error saying its not loaded yet.

sour fulcrum
#

what causes the other scene to load?

brave robin
sour fulcrum
#

not quite sure how unity editor handles that

#

but .AfterSceneLoad is what it says

#

it might not be after the scene your looking for

brave robin
#

It appears to be random, or in reverse order, as it sees scene 1 as loaded but not scene 0

sour fulcrum
#

yeah no clue

#

afaik multiple scenes in the hiearchy is purely an editor thing

#

in the context of a built game there is only 1 first scene that gets loaded

brave robin
#

Ahh, that probably explains it then. So for testing purposes I'll leave the one frame delay in, but the final build won't need it

sour fulcrum
#

have you tried your game built?

brave robin
#

Not this project yet, it's still too bare bones - not enough connective tissue yet to play it as intended

sour fulcrum
#

i'd check if your current setup works at all tbh, but I could be mistaken

potent portal
#

how do i stop this from opening all the time

#

its insanely annoying

solar hill
potent portal
#

yes

solar hill
#

because i dont think thats default behaviour

#

for me its always project files that get open

#

thats it

#

you sure you dont have any extensions?

potent portal
#

the only extensions i have are C#, C++, Python, Discord RPC, Unity, and some Themes

#

its more like it opens whenever i open vscode

solar hill
#

i think the c# dev kit does it actually

potent portal
#

sad

teal viper
rough granite
#

why does c# not like type casting from ValueType here but is fine in this other instance?

wintry quarry
rough granite
#

class

wintry quarry
#

that's why

rough granite
#

is Matrix4x4 a struct?

wintry quarry
#

yes

rough granite
#

oh.. i see ty

#

do you know how one normally gets the value from a foreach of a dictionary i used to know but after taking a short few month break forgot

wintry quarry
rough granite
#

static Dictionary<string, MeshGroup> MeshGroups = new Dictionary<string, MeshGroup>();

#

where i just want the class MeshGroup

wintry quarry
#
foreach (var value in myDict.Values)

foreach (var key in myDict.Keys)

foreach (KeyValuePair<X, Y> pair in myDict)```
rough granite
#

i feel silly now

swift crag
#

you can also do foreach (var (key, value) in myDict))

#

you can iterate over tuples of key-value pairs!

rough granite
#

sorry what's a tuple?

acoustic sequoia
#

Hey anyone, looking for some help with project settings... been looking through the shadow settings and i can't figure out how to make the shadows sharper? also my 3D objects kinda have the same issue, ex. looking at a cude from a isometric view; the 45 degree edges are 'jagged' i want this to be smooth. maybe the shadows will follow suit if that is fixed but idk

sour fulcrum
#

you can make them just by doing

(int, string) myTup = (0,"hi");
#

its nice for situations in which your dealing with paired data that isn't neccasarily related to a dict

wraith sage
#

Hello, a small question, do you know why when I press "No function" to select one, the options seen in the other image do not appear, but only "MonoScript -> string name" appears

slender nymph
wraith sage
rough granite
#

though i assume these only have one instance

sour fulcrum
#

wym

rough granite
#

nvm dw, twas a silly statement

wraith sage
solar hill
#

events are not good for continuous movement

wraith sage
solar hill
#

You should use fixedupdate to handle physics and update to handle the input

#

if youre using an rb

#

you can do something like

void Update()
{
    moveInput = moveAction.ReadValue<Vector2>();
}

void FixedUpdate()
{
    rb.MovePosition(...);
}

grand snow
#

lets remember that you want to poll inputs such as jump in Update() but something like WASD can be done in FixedUpdate()

swift crag
#

It doesn't matter so much for joystick-style inputs

#

Mouse input should not be read in FixedUpdate. It'll only tell you the amount of movement that has happened in that frame.

#

(so at a very high frame rate, your mouse would slow down: most of the mouse inputs are completely lost)

wraith sage
wraith sage
sour fulcrum
#

depends on the kinda jump, no?

wraith sage
#

yes

swift crag
#

I find it more intuitive to use callbacks for "impulse" inputs, like jumping, attacking, etc.

ivory bobcat
# wraith sage And why the update and not fixedUpdate?

Fix Update by default occurs 50 times per second in the best given scenario. Update can occur more often and will occur at least once each frame. So if you had input for a single frame (button pressed but not held), logic in Fix Update (which might not have occurred that frame) might not behave the way you'd expect it to.

swift crag
#

If you need very tight control over execution order, then you want to manually check the state of the action

grand snow
swift crag
#

it's hard to tell that you typo'd a method name

grand snow
#

how so?

swift crag
#

(in the "Unity Messages" mode, that is)

grand snow
#

Nah im a get the action and sub to a real event kind of guy

swift crag
#

That's what I always do

grand snow
#

I avoid magic invoke a function bullshit as much as possible

swift crag
#

(and then i even unsubscribe when the object dies!)

swift crag
swift crag
#

otherwise I am haunted by the Ghost of Play Mode Past

grand snow
#

we should unsub anything relating to a mono thats being destroyed

rough granite
swift crag
#

(it's certainly a good motivator, though :p )

#

it forces you to clean up after even "singleton" objects, like the player

grand snow
#

I can never turn off domain reload because i like static things too much

sour fulcrum
#

clean up your statics then 😛

rough granite
#

man spent 10 minutes trying to debug why my function wasnt working then realized i had the < in the for loop a > 😭

wraith sage
#

What did I miss, why doesn't it print the message when I move the mouse?

opaque vine
#

Hey, guys I just wanted to ask a question really quick how do teams or people currently track and diagnose build time increases in. Do developers manually review editor logs and compare them when build times increase, or do you use a system to monitor build regressions? Like when builds explode from 50 mins to 2 hrs. Or sum like that

modern lodge
#

is there a way to get a list of all of the variables within a class? or rather, is that ea list of all the animatable binding.propertyName s ?

I'm trying to figure out what all the possible binding.propertyName values are without putting a bunch of keyframes and printing out what type they are 😭

wintry quarry
modern lodge
#

ill look more into reflection, thank you!

wraith sage
supple flume
#

What are these stuff
I remember seeing them last year and it took me around an hour to find where I saw it

mint imp
#

Hey guys so in my game when you feel done with a level i want the player to press & hold a certain input for 5 seconds.
Then it would play a little animation and show an overview screen.
While holding the input the player should be vulnerable and unable to do anything

What would be the best way to disable multiple player related scripts during this period of holding the button down.
I dont want player to be able to move, look around, attack, all different scripts.
Looking for a better answer then having all these scripts subscribe to the event I'm calling from the script handling the press & holding input and exiting game code

I have this code that sends this event outward and have it effecting only my movement script right now.

#

Feel like i could broadcast to the entire object or something?
or maybe a manager that hears the inputs and effects all other scripts through public methods?

#

Better image

ivory bobcat
#

!code

radiant voidBOT
mint imp
#

oh interesting
My code isnt relevant to the question anyways i guess, just have had people ask for it before

naive tapir
#
   void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log ("clicked");

            mouseStartDownPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Debug.Log(mouseStartDownPos);
        }

        if (Input.GetMouseButtonUp(0))
        {
            Debug.Log("click released!");
            mouseDownPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Debug.Log(mouseDownPos);

            Debug.Log("Total Drag Distance Is" + (mouseStartDownPos - mouseDownPos));
        }
    }

The last Debug Log prints fine the first time, but for some reason every other time the coordinates appear as zero, why is this?

spare mountain
ivory bobcat
# naive tapir

Click and release have the same value so it would be zero if you subtract the two. For example, 1 - 1 = 0.

#

Also, make sure to remove collapse mode in the console window.

naive tapir
naive tapir
#

Uhh What’s the issue

slender nymph
frail laurel
#

i didn ping

#

i need hlp

naive tapir
#

My first bit of advice when asking for help is to at least like say what you need help with

#

Instead of sending a no context picture of something that gives zero indicator of what the issue is

#

Also I’d do what the moderator or whoever the other guy is is saying

spare mountain
naive tapir
#

That’s the weird part

spare mountain
#

Sorry

#

In getmouse

#

So it's every frame

naive tapir
#

Alr

#

1 sec

rough granite
# frail laurel

Lets not ask the same thing in multiple places especially when it isnt related to the channel.
Ps i gave you your answer

naive tapir
spare mountain
rough granite
spare mountain
#

Just to test

naive tapir
ivory bobcat
# naive tapir Yes, which is weird, they shouldn’t have the same value if it returns the correc...

Log the mouse position as well and more information if possible ```cs
void Update()
{
if (Input.GetMouseButtonDown(0))
{
mouseStartDownPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Debug.Log($"Mouse Button Down. Screen position: {Input.mousePosition}, World Position: {mouseStartDownPos}");
}

    if (Input.GetMouseButtonUp(0))
    {
        mouseDownPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Debug.Log($"Mouse Button Up. Screen position: {Input.mousePosition}, World Position: {mouseDownPos}");

        Debug.Log($"Total Drag Distance Is {mouseStartDownPos} - {mouseDownPos} = {mouseStartDownPos - mouseDownPos}");
    }
}```
spare mountain
rough granite
spare mountain
slender nymph
#

this is a perspective camera, isn't it?

naive tapir
naive tapir
ivory bobcat
#

||The world position would be where the camera is unless you provide some other value for z||

naive tapir
#

That might be why....

slender nymph
#

that's exactly what is happening, as explained in the link i sent

naive tapir
#

Thank you all for your help! It's getting late in my timezone, I ought to get going.

#

Thanks again!

gaunt cipher
#

Is there something that preserves transform values? Like I'm kinda annoyed that Transform is a thing that holds a position a rotation and a scale but if you try to snipe off Transform into a variable you just store a reference to transform. So when I want to preserve something I have to do Vector3 pos = x.transform.position, Quaternion rot = .. and so on

#

like a struct that contains two vector3s and a quaternion

sour fulcrum
#

you could make that struct

gaunt cipher
#

so I figured I would cover my bases

gaunt cipher
wintry quarry
verbal dome
#

I guess the scale could be different if sheared or something?

nova quest
#

hi all. has anyone run into this issue with unity before? revert doesnt fix the issue. deleting Usersettings/layouts didnt work. deleting library didnt work.

midnight plover
nova quest
#

yes when opening the editor, when it gets to "open scene". i dont see the main unity UI so i cant do window > layouts > reset

midnight plover
#

For future topics, this is not a coding issue, so #💻┃unity-talk would fit better next time 🙂

nova quest
#

yes, same with quit. and revert just opens the popup again. thanks sorry about wrong channel

#

oh, cancel finishes loading but i dont see the main unity UI, but i can see the menu bar options not greyed out now

midnight plover
#

Did you try to open it with another editor? I guess, there is some broken unity editor files being the cause

nova quest
#

oh that worked, it opened a panel and i was able to add scene to it

midnight plover
#

Oh, so its fixed?

nova quest
#

yes, i clicked cancel and it opened one of my panels but not the main ui, then i went to add tab and added scene, and back to where i was

midnight plover
#

Nice 👍

nova quest
#

it happens every restart, im gonna see if i can do window -> layouts -> reset

midnight plover
spare vigil
#

wondering something before i develop a possibly bad habit

is there any difference between the two? is one recommended over the other if they're the same functionally?

vs

float yValue = Input.GetAxis ("Vertical") * Time.deltaTime * moveSpeed;
midnight plover
spare vigil
#

oh yeah im just working thru this tutorial and they're using this one for ease sake i guess

#

i figure they will move onto the new input system later

#

well beside readability i think what i am mostly concerned with is with the first one the value is being modified in the arguments of the method and the 2nd example they're modifying the value within the variable itself

#

in my mind changing the value would be done in the method or arguments (?) rather than at the variable level because the variable should just stay what it is until it gets changed by a method

sour fulcrum
#

It's good to get into the habit of thinking about what your doing like this but in this case your overthinking it a little imo

spare vigil
#

yeah im sure hahaha

plucky peak
#

erm, i have a bit of question if anyone has the time

sour fulcrum
#

because the variable should just stay what it is until it gets changed by a method
this bit is a poorly steered conclusion i think

#

espicially when in the second example it is being changed by a method, the one that code is in 😛

umbral jetty
#

Guys i wanna make 3d platformer with no coding experience at all

#

i barely know variables, get components, instantiate and other basic stuff

#

but that is all

spare vigil
#

i guess ultimately it is all within Update()

#

so maybe i am just looking at it incorrectly

sour fulcrum
#

ah i didn't have that context, yeah ideally you'd probably have that stuff in a seperate function/method and just call it from update

#

something like MovementUpdate() etc.

spare vigil
#

genuinely that is probably some later step in this tutorial, im just getting ahead of myself

#

thank you for the responses! gonna get back to it and try not to overthink things

#

part of it is just me trying to work thru what it is im doing i guess

#

rather than just following along and not retaining it

sour fulcrum
#

forsure

midnight plover
# spare vigil genuinely that is probably some later step in this tutorial, im just getting ahe...

I generally try to go by the rule of reading the code as words. If you still can understand it without going on the same line several times to explain to yourself, whats happening, you got a good base. Of course, you will get into the habit of using linq and expressions to reduce code but they would still be readable and "easy" to understand. But thats something you develop over time. Where it makes sense to reduce code and where to use local variables and what not.

plucky peak
#

im a beginner and im trying to deal with vectors. there is a missile that shoots from a ship, and i want it to go into the direction of where it shoots. however i am having trouble with trying to make my direction accessible across functions. https://hastebin.com/share/nuradicoco.csharp

midnight plover
plucky peak
#

yeah, im very new, so im not entirely sure what im exactly doing

#

but im trying to play with vectors and i am assuming that in the direction of the enemy in accordance to the missile position

#

it would go to that location?

ivory bobcat
#

Assuming direction is public

plucky peak
#

hmmm, but would direction still be the transform.position - enemy.position?

#

is that how you'd determine a vector?

ivory bobcat
#

Ownership question. Who should direct where to bullet goes?

midnight plover
#

But you updating the direction does not have any effect for now, because your fixedupdate is using the movement vector from Start().

plucky peak
#

player

midnight plover
#

Which should be right, but does make update() useless in that case.

ivory bobcat
#

(Unless it's some sort of heat seeking missile where it ought to adjust itself according to some target)

#

The shooter would still provide the target in the above case though

plucky peak
#

let me give some more context, the player is able to rotate, not move, but how would you find the data on direction they face? i think i am having trouble on that and attempting to move that infomation towards PlayerMissile

#

*rotation of player is determined by mouse position

sour fulcrum
#

Transform component contains .forward which is a Vector3 pointing forward

midnight plover
plucky peak
#

i think transform.forward is absolutely perfect for my case. im not trying to make a heat-seeking missile, i just want it to shoot from the direction of the player

midnight plover
ivory bobcat
#

2d would be right

midnight plover
#

true. forward is always 0 on z in 2D 😄

sour fulcrum
#

oh btw, regarding this in your code

     //MovePosition expects a Vector2, but I am sending in a Vector3.
        //why am I doing it this way?
        //what is happening when I send it in?
        rb2d.MovePosition(transform.position + movement/1000f);

A lot of things with a Vector2 param will accept a Vector3 and just remake a Vector2 using the 3's x and y

#

it's just a convience thing

plucky peak
#

gotcha

#

tysm

#

another question

#

would i need to do anything within my playerscript, or can i just do everything within my playermissile? i am able to get information of the player from this script, so i don't think at the time i need anything from my player, right?

midnight plover
plucky peak
#

gotcha, i think, i dont need to make anything in the player script, as i just only need position of the player so it should be fine

#

tysmm guys i appreciate it

#

ill look into transform.right

errant breach
#

Hello, do i make a mistake ? Because my script cannot access c_EnemyAmount;

My script :

  • private ProgressionScript progessionScript;
  • progessionScript.c_EnemyAmount += 1;

Crashes the game with the error :

NullReferenceException: Object reference not set to an instance of an object EnemyScript.Activate (System.Single timeBeforeSpawn)

But in another code (from a tutorial), this work just fine.. And i dont understand

Thanks !

midnight plover
#

or not at all which would explain it

errant breach
midnight plover
errant breach
#

The progressionScript is on the "Content" object, and i dont use getcomponentinchildren or findbytype or whatever because the tutorial didn't use any so im lost.
Here's how i do it :

private ProgressionScript progessionScript;
progessionScript.gameProgressions.c_EnemyAmount += 1;

midnight plover
# errant breach The progressionScript is on the "Content" object, and i dont use `getcomponentin...

blindly follow a tutorial is not the best way. in c# language your line just says:

create a "placeholder" for some script with the type ProgressionScript that is only accessible to this class (private). but the actual reference is never assigned, so this line
private ProgressionScript progressionScript;
can be read as
private ProgressionScript progressionScript = null;

So to actually tie it to an object, you gotta assign it with the runtime object in your scene. Either make it public and dragdrop it, or find it once on start/onenable or wahtever you prefer with Getcomponent or FindObjectByType or or

midnight plover
silk night
#

!collab

radiant voidBOT
# silk night !collab

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**

wintry quarry
desert vault
#

Does anyone know why this happened?

rich adder
desert vault
onyx blaze
#

Someone can help with interfaces? :/

slender nymph
onyx blaze
#

Ah, sorry
Is because I'm trying to implements an Interface about Naninovel asset, but the developer never helps
Just send the Unity documentations :/

#

I'm new with interfaces, then I'm very confuse

rich adder
#

still vague

grand snow
hexed terrace
radiant voidBOT
onyx blaze
grand snow
#

keep it in one message

polar acorn
onyx blaze
#

Okay
In a big resume, I got so many errors when I tried to use the interface
But I'm confuse about it

CS0535: Member does not implement interface member.

slender nymph
#

you need to implement the methods that the interface declares

#

that is literally the entire requirement of implementing an interface

rich adder
#

time to go back to basics

night gate
#

does anyone know how to stop getting server tick batching warnings in NFE, been getting em since i made the project lmao

onyx blaze
#

Like everything empty?
But, will not get errors?

polar acorn
#

The IDE can even create the stubs for you

polar acorn
slender nymph
polar acorn
#

Because that's what they contain

#

If you don't want them to throw exceptions, you should put code in there

onyx blaze
#

Wait, wait, each one are tell a different thing
I'm trying to solve it since weeks :/

slender nymph
#

you need to actually implement a body for the methods

grand snow
night gate
hexed terrace
#

Compile errors will be gone.
Runtime will give you exceptions.

grand snow
#

can we stop all saying the same shit

night gate
#

the less likable networking option

onyx blaze
#

Probably I'll lost this job, because I'm the only programmer in years and I need to do everything alone

slender nymph
#

holy shit, you're getting paid to do this and you have no idea how to implement an interface?

polar acorn
#

Not that it's different

rich adder
hexed terrace
sour fulcrum
#

pls i need my first job

rich adder
#

taking a job / getting as programmer without knowing how interfaces work is wild

cosmic quail
#

probably a scam job that isn't planning to pay him 🤔

night gate
#

plus

#

being the only programmer

#

plus the only programmer in years

#

did they specify they wanted whatever it is to be made in unity 😭

midnight tree
#

Oh my god, my eyes are burning from the toxicity in the chat...

night gate
sour fulcrum
#

ts just a rough industry

night gate
#

like what kinda company is needing a unity game (specifically one involving complex interfaces and the such) out of the blue and only hiring one programmer

#

im not saying i dont believe them like it sounds believable it also just sounds odd

night gate
midnight tree
night gate
#

ah okie

#

im surprised no one just

#

asked what they need an interface for

night gate
slender nymph
#

they're trying to implement a third party asset that requires the use of it

night gate
#

ah

#

what asset did they say

rich adder
#

Naninovel asset

onyx blaze
night gate
#

average management decision tbf

rich adder
#

whats that got to do anything with it...nothing wrong with using a paid asset..

#

especially if the company foots the bill..

#

why reinvent the wheel if you have asset doing what you need

grand snow
night gate
rich adder
# night gate im just judging the company

sorry but have you worked in a company before? pleenty of companies aquire different software for specific needs.. it wastes more money coding everything from scratch and mantaining it..

#

alas veering offtopic anyway..

grand snow
#

Its a no brainer to spend like £50 to save a few days work

slender nymph
grand snow
#

nice to see UniTask though

night gate
onyx blaze
#

So I need to create a ResourceProvider that Allows me to read this DLC content

sour fulcrum
grand snow
onyx blaze
grand snow
#

That does not make sense

polar acorn
grand snow
#

Are you thinking of a project setting scriptable object instance?

onyx blaze
#

I'm trying to understand how to do this ;-;

sour fulcrum
#

Not to derail the direct question but just a kinda vibe check with no disrespect, whatever solution you end up going here is probably gonna take you some time to learn about parts of what needs to happen here

#

just make sure you have the time budget necessary for that

polar acorn
grand snow
#

Guys its clear they dont really need to do this

#

They somehow think getting project settings data needs some silly solution. They should just be in a scriptable object somewhere

polar acorn
#

I don't know the asset, so I don't have any context for what it's supposed to be

grand snow
#

TMP for example already does this but their settings are in a scriptable object in Resources

onyx blaze
#

Is because I cannot show the game here
I have a video about this dlc

slender nymph
#

you need to actually provide a proper description of what your goal here is, because right now this really seems like an XY Problem

onyx blaze
#

I have the Naninovel Asset, that is to do Visual novels
This asset uses the ProjectSettings to set the files the will be read, like dialogue scripts, as example

#

But when compiles the game, ProjectSettings isn't accessible anymore
To this I use a folder "DLC" to add the characters files that I need
Some files as images or sounds works because don't need to be inside the Project settings

slender nymph
#

why can you not configure it before building the game

onyx blaze
onyx blaze
slender nymph
#

whatever. continue the explanation, and for the love of all that is holy stop breaking the explanation up into multiple messages. it is incredibly fucking annoying to have to read only a small part of the explanation and then wait several minutes for even a crumb of context

onyx blaze
#

I don't want trouble

#

Sorry

acoustic maple
#

I added a tag to a the ball in my pinball game now it falls through the floor

slender nymph
#

tags have nothing to do with physics/collisions. are you certain that the colliders/rigidbody are set up correctly

acoustic maple
#

I was adding a collision to a bumper. The only thing I changed was making it a trigger

slender nymph
#

trigger colliders do not provide physical collisions

acoustic maple
#

Thanks

#

How do I wait for an animation to end?

slender nymph
#

use an animation event

acoustic maple
#

Is that code?

#

Sorry I am new

slender nymph
#

you know you can google things, right?

queen vale
queen vale
# acoustic maple Is that code?

Select the object containing the animator (0) > select the target animation > create an event (1) > select / place the event marker where it needs to trigger within the animation (2) > select a function within the script attached to the same gameobject, ie your script & function need to both exist on the gameobject that contains the animator (3).

acoustic maple
#

bc the button is grayed out

queen vale
#

Which button?

acoustic maple
#

add event

#

the animation is read only

queen vale
#

Go to the asset/animation within your "Project" tab, select it.

#

Ctrl+D to duplicate it.

#

Make adjustments to the duplicated file

acoustic maple
#

I found it is in the main fbx

queen vale
#

I'm not sure that I understand? What is in the "main" fbx? When you import a model/fbx that was animated within blender, so long as your export settings were correct, it should still carry the animation. When selecting the initial (within Unity/"Project") import file you have options to generate colliders, carry over materials, and import animations.

acoustic maple
#

I have the code but cant call it. I am getting this error 'bumper' AnimationEvent 'endbumperanimtion' on animation 'Cone|ConeAction' has no receiver! Are you missing a component?

slender nymph
#

do you have a method with that name on a component that is attached to the same gameobject your animator is on?

acoustic maple
slender nymph
#

void is a return type for a method, but it is not the only return type. in this case the method you write for the animation event should return void

acoustic maple
slender nymph
#

there are beginner c# courses pinned in this channel, start there if you don't know how to write a method. but if you came from java then you should already understand what methods are and how to use them, as well as return types.

solar hill
cosmic quail
#

c# is basically identical to java in almost every way

polar acorn
acoustic maple
slender nymph
#

then you didn't really "come from java" if you barely even learned the basics

solar hill
#

also what basic class would not teach you the other types??

sour fulcrum
acoustic maple
slender nymph
#

that makes literally 0 sense

sour fulcrum
#

your teacher is stupid but thats besides the point

acoustic maple
#

I can do alot in game maker but they use a wierd propritary language.

acoustic maple
solar hill
#

what

slender nymph
#

still doesn't make sense. you can use methods to modularize and organize code within a class, but that doesn't really have anything to do with the method's return type

swift sedge
#

you use any method to reorganise code, regardless of return type
the return type is only there to take it one step further and actually return some data from a method call

cosmic quail
#

splitting code into methods does help organize it better

queen vale
solar hill
#

UnityChanHuh thats not what i was responding to

#

but ok

queen vale
#

my bad 😓

edgy tangle
#

I think probably teachers teaching beginners lean into just using void return types because explaining returns just adds more stuff that might confuse beginners

verbal dome
#

I'd say that not understanding return types leads to more confusion

#

Such a fundamental concept

edgy tangle
#

Could be. I remember when I started out I didn’t really get it for a while, but that may also have been due to following tutorials that only really ever used void return types

#

Just playing devil’s advocate that I could understand why that topic wouldn’t be covered right away

queen vale
#

I'm not formally educated in any of this, are we talking about

public GameObject Get_Menu()
{
  return menu.gameObject;
}
#

🥲 the sweating face does not give me confidence

cosmic quail
queen vale
#

Ahhhhh, need new glasses lol

cosmic quail
#

they were talking about method return types and GameObject is indeed the return type of your example method

edgy tangle
#

Back to @acoustic maple’s problem… yeah you need to have a public void method on a script attached to the same GameObject as the animator with the EXACT same name that you put on the AnimationEvent

#

I’m not positive if it MUST be a void return signature, but unless there’s a specific signature the animator can use then it won’t do anything with return types anyway

#

I don’t know how it works under the hood but I assume it’s using SendMessage

queen vale
acoustic maple
#

thanks

queen vale
#

As for the no reciever part, you need to make sure that:

  • There's an animator component on the gameobject.
  • The script with the desired function / behaviour is on that same gameobject.
swift sedge
acoustic maple
#

time to work on geting the bumper to put more force on the ball to be relistic

floral garden
#

Hi, i got an question while following a tuto , with the new input system
he put an input and a getter like

functionInput
// turn true the bool associated with it touch

then a function get
turn it off
and return true
else
false

is it a good way to manager the button ? will it have a data race ?

verbal dome
swift sedge
#

also, Luau goes one step further and supports union types, i.e. (number | string) can either be a number or a string, which I think is so cool

acoustic maple
queen vale
grand snow
#

any moment

polar acorn
wintry quarry
queen vale
grand snow
#

wasted effort if you ask me

queen vale
#

Only takes a moment, besides procrastinating on my project atm lol

timber nacelle
#

i might be kinda annoying but i just saw a youtube video of a tutorial on how to make a player with movement, but the game is just spamming: "invalidoperationexception: you are trying to read input using the unityengine.input class, but you have switched active handling to input system package in player setting"

#

i already got 999+ error outputs with the same message lol

solar hill
#

!Input

radiant voidBOT
# solar hill !Input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

solar hill
#

set it to both

timber nacelle
#

what do i do? i have unity since yesterday 😐

#

so im a pretty big noob...

timber tide
#

Project Settings > Player > Active Input Handling

grand snow
#

basic computer literacy required

timber nacelle
#

yessss it works now, thanks

verbal dome
#

It says what Mao said

#

Not gonna get very far if you dont read instructions

wraith sage
#

Isn't it wrong to move the camera at the event instead of updating? To avoid unnecessary executions when the camera is not moved? I ask because they put it in update everywhere, I don't know if it's because it's not recommended to do it the way I did, or because they didn't think about doing it that way. (the camera works without problems)

floral garden
#
        private bool _submitPressed = false;

        public void SubmitPressed(InputAction.CallbackContext context)
        {
            if (context.performed)
            {
                _submitPressed = true;
            }
            else if (context.canceled)
            {
                _submitPressed = false;
            }
        }

        public bool GetSubmitPressed()
        {
            bool result = _submitPressed;
            _submitPressed = false;
            return result;
        }
    // for any of the below 'Get' methods, if we're getting it then we're also using it,
    // which means we should set it to false so that it can't be used again until actually
    // pressed again.

this is the text he putted in the github

wintry quarry
wintry quarry
#

whatever code is consuming GetSubmitPressed() should just run inside the SubmitPressed input listener.

#

or should be subscribed to an event fired from there

white zinc
#

does anyone know why this doesnt work? It is suppose to get a random float from 1 to 5: randomValue = UnityEngine.Random.Range(1, 5);

wintry quarry
#

but no there's nothing in here that is a "race" of any kind

wintry quarry
floral garden
#

and about the data race as all update is random (i think)
if 2 update use the input, one will be ignored
this is what my question

floral garden
#

or should I create one?

white zinc
#

I created a public float that should show the value in the inspector but it is always 0

floral garden
#

are you sure you set the value ?

solar hill
floral garden
#

log the value then

solar hill
#
randomValue = UnityEngine.Random.Range(1f, 5f);
white zinc
wintry quarry
white zinc
# solar hill ``` randomValue = UnityEngine.Random.Range(1f, 5f); ```

it still doesnt really work: ```using UnityEngine;
using UnityEngine.UI;

public class BarSliderRotation : MonoBehaviour
{
public FNAFCamera fnafCamera;
public Slider slider;

public float randomValue;

private bool hasTriggered = false;

void Start()
{
    if (slider != null)
    {
        slider.minValue = 0;
        slider.maxValue = 100;
        slider.value = 0;
    }
}

void Update()
{
    if (fnafCamera == null || slider == null) return;

    slider.value = fnafCamera.rotationPoints;

    if (fnafCamera.rotationPoints >= 100f && !hasTriggered)
    {
        randomValue = UnityEngine.Random.Range(1f, 5f);
        hasTriggered = true;
    }

    if (fnafCamera.rotationPoints < 100f && hasTriggered)
    {
        hasTriggered = false;
    }
}

}```

wintry quarry
#

That's what SubmitPressed is

solar hill
wintry quarry
solar hill
#

give randomValue a default value like 20

#

if it shows up as 20, then you know that youre never reaching random.range

wintry quarry
#

Nothing to do with the Range function

white zinc
solar hill
#

did you change the default value in the inspector or the code?

#

its a public value, the inspector will always override it

floral garden
white zinc
solar hill
#

right...

#

so yes your If statement is failing somewhere

#

most likely your fnafCamera.rotationPoiints

floral garden
queen vale
#
using UnityEngine;
using UnityEngine.UI;

public class BarSliderRotation : MonoBehaviour
{
    public FNAFCamera fnafCamera;
    public Slider slider;

    public float randomValue;

    private bool hasTriggered = false;

    void Start()
    {
        if (slider != null)
        {
            slider.minValue = 0;
            slider.maxValue = 100;
            slider.value = 0;
        }
    }

    void Update()
    {
        if (!fnafCamera || !slider) return;

        slider.value = fnafCamera.rotationPoints; // How is this value getting set?
        Debug.Log(fnafCamera.rotationPoints);

        if (fnafCamera.rotationPoints >= 100f && !hasTriggered)
        {
            randomValue = UnityEngine.Random.Range(1f, 5f);
            hasTriggered = true;
        }

        if (fnafCamera.rotationPoints < 100f && hasTriggered)
            hasTriggered = false;
    }
}
solar hill
#

log the value of that at the top of your update

floral garden
#

why don't you toggle debug and place a break point?

solar hill
#

its almost certainly fnafCamera.rotationPoints, my question is whats the point of setting sliders.value to it but then just using the rotationPoints in your if statements anyways

floral garden
#

what the print value of rotationPoints?

white zinc
#

from 0 to 100

#

and it resets to 0 when reaching 100

ionic mirage
#

hello wonderfull people hope evryone have a great weekend im looking for help right now it been 2 day trying to figure out why my new character dont want to move beofre i had a captuse and move normaly after download character only camara rotate left and right

floral garden
#

2d ? 3d ? Rigidbody or Character controler ? new input system or old ?
keyboard or xbox controler ?

queen vale
# white zinc and it resets to 0 when reaching 100

What we know

  • It found the camera & slider.
  • The rotation points is updating in value and reaching 100.
  • The hasTriggered by default is false, leaving the first if statement possible but not functional.

Is rotationPoints an int or float?

grand snow
#

I am confused what this is even trying to do

floral garden
#

maybe float accuracy ?

queen vale
#

Strike what I said, int/float shouldnt matter..(?)

queen vale
#

It's >= so regardless so long as the value is met or exceeded

solar hill
#

maybe its not reaching 100?

#

maybe its goes to 99 and gets reset to 0

floral garden
queen vale
#

^^^ mod-10 counter

#

As soon as the 7-segment display reaches 10 it goes back to 0, never displaying 10

ionic mirage
queen vale
floral garden
#

hmm firstly i recommend you to use only one
New or Old
then for the question
from what i see , it is maybe a CC
can you show where you make the move?

ionic mirage
#

already try new and old nothing just the vcamara rotate left and right and jump

hexed terrace
#

!vscode

radiant voidBOT
floral garden
ionic mirage
#

it was working before i download the character

#

anyways i can do screen share?would be faster?

floral garden
#

yes but does your input work ? I don't think we can do it here for the screen share

ionic mirage
#

how can i check if my imput wwork?

floral garden
#

place a log after the input in your code