#πŸ’»β”ƒcode-beginner

1 messages Β· Page 152 of 1

swift crag
#

you need to copy the texture's contents (or make two render textures)

languid spire
#

isn't there a texture = new Texture(renderTexture); to make a shallow copy?

swift crag
#

That sounds plausible to me, yes

rich adder
#

yeah this reference type

#

its same texture

swift crag
#

This is one area where I don't have much experience, alas.

queen adder
#

Trying to sort a list but i think im doing it wrong somehow?

swift crag
#

I played with RTs in a game jam once where I spent most of the jam creating a procedural level generator instead of making the game fun

#

whoops

rich adder
swift crag
#

but if that hard read was wrong, context please!

queen adder
#

Im about to copy and paste the code give me one second

#

But yes ur right

#

Using OrderBy

languid spire
#

you didn't read the docs then did you

swift crag
#

That produces a new IEnumerable<T>, as do all LINQ methods.

#

consult the docs for List<T>

#

you will find what you need

rich adder
#

reading docs is overrated. /s

languid spire
#

heretic

queen adder
#
{
    _current_index = 0;

    PlayerPawns = FindObjectsByType<PlayerPawnBase>( sortMode: FindObjectsSortMode.None ).ToList();

    PlayerPawns.OrderBy(pawns => pawns.BattlePawn_SO.SpeedOrder ).ToList();

    for(int i = 0; i < PlayerPawns.Count; i++)
    {
        print($"{PlayerPawns[i].BattlePawn_SO.CharacterName}");
    }
}```
swift crag
#

you order the enumerable, create a list, and then...throw the list away

queen adder
#

Oh really

swift crag
#

yes really

queen adder
#

I didnt realize

swift crag
#
AddTwoNumbers(3, 5);
#

it's like you did this

#

the answer is 8. but you do nothing with the answer, nothing happens

oblique ginkgo
queen adder
#

So im not returning it correctly?

swift crag
#

you seem confused

languid spire
#

your not returning it at all

queen adder
#

I am lmao

swift crag
#

look at the methods you're calling instead of just hoping they do what you think they do

#

OrderBy takes an enumerable and produces a new enumerable.

queen adder
#

I see

swift crag
#

ToList takes an enumerable and returns a list containing the enumerable's elements.

queen adder
#

Makes sense

swift crag
#

now, you COULD write this:

PlayerPawns = PlayerPawns.OrderBy(...).ToList();

This would be a valid program, and it would do what you want it do (make PlayerPawns be a sorted list)

queen adder
#

Yeah^^

swift crag
#

however, this means that you're throwing out the old list and replacing it with a new one.

#

this does not sort the list referred to by PlayerPawns

#

it stores a new list into that variable.

#

on the other hand...

queen adder
#

I see simple mistake on my part

swift crag
#

You should not be using OrderBy...ToList at all here.

#

There's no point. Just call Sort.

languid spire
#

and generates shit loads of garbage to boot

swift crag
#

indeed

#

Now, there is one downside to List<T>.Sort

queen adder
#

Which is ?

swift crag
#

It's more awkward to use a custom comparison function.

#

oh wait, no it's not

#

very nice

robust kelp
#

i did this and for some reason the movement is laggy, velocity isnt clamped exactly to its max speed it just changes really fast from 20 something below maxspeed to 20 something above

swift crag
#

Comparison<T> is a delegate type

swift crag
queen adder
#

I get it now

swift crag
#

rather than a method that turns a PlayerPawnBase into a comparable value.

queen adder
#

It was a really simple mistake

#

Thank u for ur guys help πŸ™‚

swift crag
robust kelp
#

yea

swift crag
#

then just clamp that and be done with it

#

your code is clamping the XZ and Y velocities whenever the total velocity gets too high

#

that's going to be very unusual looking

silver sun
# languid spire and generates shit loads of garbage to boot

finished it:

https://pastebin.com/i6nhayGg

but i get this:

NullReferenceException: Object reference not set to an instance of an object
Planet.OrbitPlanets () (at Assets/Scripts/SolarSystem.cs:109)
Planet.Update () (at Assets/Scripts/SolarSystem.cs:96)

rich adder
#

oh wait u pasted 2 classes..

rocky canyon
#

Object reference not set is always b/c ur trying to access something thats null

rich adder
#

smart

#

yupsomething is null on 109 of solarsystem script

#

who knows what because they pasted 2 scripts in 1 link

stable ore
#

!code

eternal falconBOT
rich adder
#

not including the namespaces

#

so who knows

stable ore
#

whats wrong with this code?wehn i run it the movement is inverted so when i press w it goes left if i press s it goes forward or backwords

#

who is blud talkin too

swift crag
#

click on the object that NewBehaviourScript is attached to

stable ore
swift crag
#

make sure your scene view is in local + pivot mode

#

The blue arrow you see is forwards.

silver sun
swift crag
stable ore
#

alr is

swift crag
#

If the blue arrow doesn't point in the direction you think should be forward, then you need to adjust something.

stable ore
swift crag
#

indeed, you're off by 90 degrees

swift crag
#

here's my suggestion

stable ore
#

is it in blender i gotta change

swift crag
#

parent this model prefab to a new empty object

rich adder
#

Blender

swift crag
#

Then you can just rotate the model however you need to.

#

You could also fix it in Blender, yes

stable ore
swift crag
#

Also, I see that you have a rigidbody on the model.

#

since you do, you should not be using transform.Translate

#

you should be moving the rigidbody itself

swift crag
stable ore
rich adder
swift crag
#

unlike transform.Translate

#

Just use transform.forward instead of Vector3.forward and it'll work out nicely

rich adder
#

always keep mesh as child, this way rotations/scale is incosequential to main object with logic/colliders

swift crag
#

transform.forward is the direction the transform is pointing in world-space

swift crag
#

rotate the model so that it lines up with the parent object's forward direction

#

so, when you have the parent selected, its blue arrow should match where the model is facing

stable ore
#

like this?

#

@swift crag

swift crag
#

You've parented it to a cube. I said to parent it to an empty object.

swift crag
#

So just delete the box collider, mesh renderer, and mesh filter from the cube

#

that'll give you an empty game object

#

you'll also need to move the movement component onto the root object

sullen zealot
#

hello!
is there a way to have a function executed only for the first 25 frames?

rocky canyon
#

sure.. count frames

swift crag
#

sure, add a condition that checks if Time.frameCount < 25. But what are you really trying to accomplish here?

rocky canyon
#

^ ding ding ding

tender wren
#

I am having an issue using a variable created on an object in editor.

Object1(EmptyObject) has moduleBuilder:

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

[ExecuteAlways]
public class ModuleBuilder : MonoBehaviour
{
    public static ModuleBuilder mb;
    public List<Module> modulelist;

    private void OnGUI()
    {
        if (mb == null)
        {
            mb = this;
        } else if (mb != this)
        {
            Destroy(gameObject);
        }
    }
}

Object 2 is trying to access Object1's static property:

        }
        bool addme = true;

        foreach (Module m in ModuleBuilder.mb.modulelist)
        {
            if(m.GetHashCode() == this.GetHashCode())
            {
                addme = false;
            }
        }
        if (addme == true)
        {
            ModuleBuilder.mb.modulelist.Add(this);
            print(ModuleBuilder.mb.modulelist.Count);
        }

getting this error and a nullreferenceerror:

Objects are trying to be loaded during a domain backup. This is not allowed as it will lead to undefined behaviour!

What am I doing wrong logically here?

rocky canyon
#

but yea, thers probably a better solution

rocky canyon
#

ud have to check if every frame to be accurate

#

so yes..

stable ore
#

like this yh?

swift crag
#

not "do something for the first 25 frames"

stable ore
swift crag
#

well, yes, you haven't moved the movement component yet

rocky canyon
#

thats just an optimization (better way to do it)

swift crag
#

it's still attached to the model

#

Put the movement component on the root object.

stable ore
rocky canyon
#

yup, move the main parent.. the graphics will follow along b/c of them being child objects

swift crag
#

you've managed to avoid screenshotting anything useful here

#

select the root object and show us the inspector

sullen zealot
#

i want to save the renderTexture to a sprite thorugh a function, but i have 25 sprites and if i do a for loop in start function it makes all sprites the same bc the render camera doesnt update until the next frame

stable ore
#

here

#

i attatched the script to the empty

#

and it still has incorrect movement

rocky canyon
#

and wait until next frame

swift crag
sullen zealot
swift crag
#

you should stop after you've gotten to the last sprite

#

this sounds like a simple for loop to me

rocky canyon
#

yup

sullen zealot
#

oh yeaa

#

ahahaha

#

thx

rocky canyon
#
       foreach (var item in yourArray)
        {
            // Perform actions on the current item

            // Wait for one frame
            yield return null;
        }```
stable ore
#

it works @swift crag

#

LESS GOO

rocky canyon
#
 private IEnumerator DoActionsWithDelay()
{```
swift crag
#

if you want to have a rigidbody, then put it on the root object and control its velocity or position

rocky canyon
#

ofc ud need to put it in a coroutine to use the yield return

stable ore
#

now i gotta figure out why i shouldnt use transform.translate

rocky canyon
#

you can

#

no ones stopping you..

#

its basically just teleporting

stable ore
swift crag
#

If you have interpolation enabled, setting the transform's position won't work.

#

The rigidbody will overwrite it.

rocky canyon
#

ahhh true true

#

rb.MovePosition

#

is a good one

swift crag
#

MovePosition() tries to respect colliders as it moves, yes

rocky canyon
#
   // Move the Rigidbody using MovePosition
        rb.MovePosition(rb.position + movement * moveSpeed * Time.deltaTime);```
stable ore
#

i can tell @rocky canyon is about to loose his braincells

#

from me

rocky canyon
#

you should only call (1) of those methods not two.. just add the vectors and stuff into a variable together

#

and only call the rb.MovePos. once..

rich adder
#

why not just use character controller

#

also moving RB in update is wrong

stable ore
#

would this be right?

rocky canyon
#

The Rigidbody.MovePosition method is typically used within the FixedUpdate method for physics-related operations. However, Unity automatically interpolates the movement when you call MovePosition in Update, ensuring smooth motion.

#

i think you could use it from update..

rich adder
#

interesting..

rocky canyon
#

but yea generally bad. esp if ur setting its velocity directly.. like rb.velocity = thats def reserved for FixedUpdate

rich adder
#

I haven't used MovePosition much so I was under the impression it was same as .vel or AddForce acceleration

rocky canyon
#

its b/c it runs in fixedupdate anyway.. even if ur calling from update.. it probably takes the last one that was called b4 the fixedupdate kicks in

#

but im unsure exactly.. but i know that u can get away with it.. altho probably not very proper

rich adder
#

yeah but so is addforce

rocky canyon
#

yea.. thats another one you CAN use in update..

#

but i wouldnt anyway

#

yea but anyway.. he's right..

#

commonly keep ur rigidbody stuff in fixedupdate

stable ore
#

what should i use then?

rocky canyon
#
  • get input from update
  • act on that input in fixedupdate
rich adder
#

I just know it from everyone preaching it like gospel lol

stable ore
#

for my movement thats the best

rocky canyon
#

what type of game are you making?

stable ore
rich adder
#

for simple movements I just usually go with CC

rocky canyon
#

tbh CC is perfect for basic stuff..

#

it has built in stuff where it can walk up slopes and stairs..

#

and can handle basic verticallity like jumps and whatnot

rich adder
#

Yeah, the only issue is going down the slops it skips but that can be fixed with getting slope normals (bit advanced topic)

stable ore
#

is that the best for mobile games?

rocky canyon
#

Rigidbody is more powerful and more natural

rich adder
rocky canyon
#

CC is easier and better for beginners to pick up on

stable ore
rocky canyon
#

you can use CC in update.. u wouldnt need to worry about splitting up ur inputs and movements

stable ore
#

and that stands for character controller right

rocky canyon
#

yessir.. you dont need a rigidbody if you go that route

stable ore
rocky canyon
#

look up Simple / Basic Character Controller for some tutorials

stable ore
#

why wont i need it?

rocky canyon
#

they're all about the same thing

rocky canyon
#

b/c CC uses a capsule collider and a CharacterController component

stable ore
#

gonna go work on my blender project

rocky canyon
#

it does math internally to get smooth movements and stuff

swift crag
#

character controllers can be reliably moved in Update and make it easy to move around and over colliders

rocky canyon
#

^ as a beginner ur probably best to use the CC and work ur way up to a rigidbody

ivory bobcat
rich adder
#

only thing with CC is you need to make your own Gravity but Unity has an example script

stable ore
#

without rigid body

rich adder
#

also you can just use the new CC starter assets.
but learning the basics on how it works it probably benefit your learning

rocky canyon
#

you will have to code in gravity yourself for the CC but thast basic..

#

you just can add a negative vector to ur variable b4 u use it in the CC move functions

stable ore
#

sounds intresting

scarlet skiff
rocky canyon
# stable ore idk what that is but will look into that
    private void Update()
    {
        // Example: Move the Character Controller with gravity
        float moveInput = Input.GetAxis("Horizontal");
        Vector3 movement = new Vector3(moveInput, 0f, 0f);
        movement.Normalize();

        // Check if the character is grounded (you might have your own ground check logic)
        bool isGrounded = characterController.isGrounded;

        if (isGrounded)
        {
            // Reset velocity when grounded
            velocity.y = 0f;
        }
        else
        {
            // Apply gravity when not grounded
            velocity.y -= gravity * Time.deltaTime;
        }

        // Move the character using CharacterController.Move
        characterController.Move((movement * moveSpeed + velocity) * Time.deltaTime);
    }```
boilerplate example
#

has built in ground checking

rich adder
swift crag
#

yes, that can cause problems with detecting grounding properly

rich adder
#

literally they could've just put a + lol

stable ore
rocky canyon
swift crag
#

isGrounded reflects the most recent movement. If you didn't move down at all, and you're on flat ground, you won't wind up with isGrounded being true

#

since you just moved horizontally over the ground without bumping into it

swift crag
peak timber
#

Is this the help channel?

rocky canyon
#

read the top description

rich adder
rocky canyon
#

im sure they do eventually

#

hell ya, get it fixed for us @rich adder πŸ™‚

stable ore
rich adder
#

make it a Github thing

#

so many docs link to github (I think the new docs they did that) Netcode

ivory bobcat
rocky canyon
# stable ore idk i used something like that in a 2d game tutorial i remember

well && just means AND in a conditional...
if (x > 0 && y > 0) or

{
    if (y > 0)
    {```
its just how the code is written, u could use a ground check with it and w/o it.. by using two if statements.. not really relevant to whether its a CC or RB but,
- a rigidbody doesn't have a built in ground check (you have to program it yourself)
- a cc does have one already
#

theres pro's and con's to each.. but CC is the fastest to get up and running a basic character for sure ⭐

stable ore
rocky canyon
#

πŸ‘ good luck

stable ore
rich adder
rocky canyon
#

^ yup drag and drop bb

stable ore
rich adder
#

idk what roblox type movement is but this should work no?

rocky canyon
#

ahhh beat me

rich adder
#

you got both which is prob better πŸ™‚

rocky canyon
#

well the quicker u get the bones set up the faster u can build / modify it to be a good system

stable ore
rich adder
#

is roblox fpv or third

stable ore
#

or look

rich adder
#

idk even know

stable ore
rocky canyon
#

don't discount us saying quicker as half assed

#

cuz not the same thing

rich adder
#

you just need to tweak them enough

rocky canyon
#

stock sucks

rich adder
#

yeah their gravity is a bit light for my taste

#

feels "floaty" (but then again its video games not realism xD)

rocky canyon
#

and drop my physics tick to be 60fps

rich adder
#

I use -20ish lol

rocky canyon
#

thats totally fine too πŸ˜„

rich adder
#

Jupiter gravity

rocky canyon
#

a bit realistic for me

#

all my projects prefix arcade- to the front lol

#

gives me an escape window..

rich adder
#

yeah I've been making just "insert activity" sims

rocky canyon
#

"well, its arcade, it isnt supposed to feel real"

rich adder
#

so jumping is kinda not really priority

rocky canyon
#

i made a joke a while ago about moving the ground downwards for a jump..
it actually works.. probably hella unperformant if i were to continue with it LoL

rich adder
rich adder
#

are you using OffMesh links?

rocky canyon
#

πŸ˜‰

rocky canyon
#

i'll try em out undoubtfully tho

tropic dirge
#

is there anyone else new here?

rocky canyon
#

i lost my leaves a while ago.. why whatsup?

rich adder
rich adder
tropic dirge
#

im a freshie

#

i have never done anything with unity other than spawn a block

rocky canyon
#

thats a decent start

tropic dirge
#

and i want to learn

rich adder
#

check out !learn

eternal falconBOT
#

:teacher: Unity Learn β†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

rocky canyon
#

damnit

rich adder
#

they have good starter courses

tropic dirge
#

courses like money?

rich adder
#

nahh

#

Unity made them

#

free

tropic dirge
#

ok

rocky canyon
#

^ facts, follow along and dont be afraid to go out looking for more information
once your exposed to a new idea, if u dont quiet understand it completely look up extra resources on your own..

#

google and youtube are chocked full of unity resources

rich adder
#

Unity answers was def my top goto from google

rocky canyon
#

if you get hardstuck or softlocked on something just come here and ask for help

rich adder
#

it still is today mostly, and the forums

rocky canyon
#

i like stackoverflow myself

rich adder
#

yeah though I find more c# stuff better there than unity

rocky canyon
#

and don't be afraid to read the manual.

#

u dont gotta tell no one

rich adder
#

lokey the manual has many good pages

rocky canyon
#

it does.. i bookmarked that VectorCookbook link i saw yesterday

#

always learning of new ones

tropic dirge
#

Time to try and do this again! (for the 3rd times)

rich adder
#

wait did Unity just do an inside joke ? or just coincidence lol

rocky canyon
#

someone needs to make more interactive tutorials..

rocky canyon
languid spire
rich adder
winter prawn
#

I was overwhelmed the first time I tried to learn

zinc plover
#

!bug

eternal falconBOT
#

πŸͺ² To make bug reporting as quickly as possible, we made a bug reporting application for you. When running Unity choose Help->Report a Bug in the menu, or you can access it directly through the executable in the directory where Unity is installed. It will also launch automatically if you experience a crash.

πŸ“ If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the bottom of the page where you found the issue and click β€˜Report a problem on this page’!

πŸ’‘If your report is to do with a new feature idea, you can check the Unity Product Roadmaps page to see if your idea has already been planned.

For more complete instructions on how to report bugs, access: https://unity3d.com/unity/qa/bug-reporting

rich egret
#

Someone know how to solve it?

rich adder
tropic dirge
#

unity isnt working

#

it wont let me reset my password

near wadi
#

Is this a safe/valid way to display strings? it just makes me worry a little using {} like that
Debug.Log($"{playerName} was attacked by a wild {animalName}");

meager raptor
#

Guys does anyone know why the colors are so bland on my editor for visual studio? Like the "Vector3" is blank etc

near wadi
near wadi
meager raptor
#

C#

eternal falconBOT
edgy fox
#

you have it configured for C# but not game development with unity

rocky canyon
edgy fox
#

still having the faux hitbox issue - I found if I move the box it thinks it is colliding with back, the raycast extends a little bit farther. It's as if the hitbox for the wall is on the left room instead of the right room

meager raptor
sleek radish
#

Preserving player's local y velocity correctly

edgy fox
#

(the raycasts extend from the center of the room to where out RaycastHit hit says it hit hit.point)

sly wasp
edgy fox
#

so it's literally as if the walls on the rightare actually around the room on the left

rocky canyon
# edgy fox (the raycasts extend from the center of the room to where `out RaycastHit hit` s...

i would start considering using a different scene.. and testing the thing a little by little..
maybe rebuilding ur pieces and trying..

idk, i watched in yesterday with this issue and im with Vertx, im stumped as to what could be happening..
at a certain point (when i have issues i can't solve) i try to start over or isolate the problem pieces to just theirselves.. to eleminate any possibility other things are messing it up..

#

try getting it working w/ the most basic of setups... and if that doesn't work then you can atleast rule out it being a bug in the project or something unexplainable..

#

but idk /shrug tbh

edgy fox
#

but it def is that object because if I mess with WallEZ's hitboxes it affects the drawn ray

#

I guess I'll just try and reconstruct it

#

see if I can replicate this bug

swift crag
edgy fox
#

and the scene has no rigidbodie

swift crag
#

That'll do it.

#

ah, no rigidbodies?

edgy fox
#

not a single one

swift crag
#

hit.transform can give you a parent transform if it hits a collider under a rigidbody

real merlin
#

quick question can i store function in an array

#

sorry if it's really dumb

rocky canyon
swift crag
#

sure, System.Action[]

#

or probably a List<System.Action>

#

if you want a list

swift crag
edgy fox
#

well I have no rigidbodies so that shouldn't be an issue

#

I get what you mean nowthough

#

brain's just running a tad slow today

swift crag
#

Show me your code (or link me to it again)

sly wasp
real merlin
swift crag
#

okay, then that'll fit into a System.Action variable

rocky canyon
# edgy fox wait wym

he means sometimes ur raycast can hit an object down the hiearchy
but the raycast will return the root

sly wasp
#

"!code"

eternal falconBOT
edgy fox
#

wait not me

rocky canyon
#

if the collider is a child object

swift crag
#

nah, I did want to see yours

edgy fox
swift crag
#

I want to see it!

#

but use a pastebin site

#

it's pretty long

swift crag
rocky canyon
#

chunkers

edgy fox
real merlin
#

because apparently it's a "delegate"

#

i wonder what that is

swift crag
#

"delegate" is the type of a function

tropic dirge
#

can someone help ne rq

real merlin
swift crag
#

it's not an array of variables or anything; you're just making an array of System.Action

#
            System.Action[] x = new System.Action[3];
rocky canyon
#
        // Create an array of Actions
        Action[] actions = { action1, action2, action3 };```
tropic dirge
#

nvm

real merlin
#

alright i see

#

thank you very much

swift crag
#

oh, I guess that is kind of an array of variables :p

#

in a sense

rocky canyon
#

just called it "Actions"

sly wasp
swift crag
#

"get the component" ?

#

you mean you want to save the blendshape indices?

spiral rain
#

Hey I am trying to make a random scrolling animation that selects a item (like what it looks like when choosing a mini game in Mario party) does anyone know how to make it or better yet a tutorial.

sly wasp
edgy fox
#

reacreated the scene re-using my scripts and obv 3D assets - same issue and I don't really know what I should change unless I just go through the process of re-coding all of my room generation functions

rocky canyon
#

maybe you can find something similar by searching Slot Machine ?

swift crag
rocky canyon
#

thats kinda what i think of when i hear random scrolling selection

swift crag
#

the blendshapes are numbered in order

#

(as far as I'm aware, at least)

sly wasp
swift crag
swift crag
#

write a for loop

edgy fox
# swift crag I'm still unclear on what your problem is (and I don't think you've shown me the...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/* Script Purpose
 *  On Room Frame instantiation:
 *  add empty walls around them
 *  add actual walls adjacent to where walls already are (to prevent one sided walls)
 */
public class AddWalls : MonoBehaviour   //Called when new room frame is placed
{
    [SerializeField] GameObject blank, cam, parObj;
    [SerializeField] BoxCollider linearOffset;
    [SerializeField] private LayerMask wallMask;
    /*
     * blank: empty gameObject
     * cam: the camera
     * parObj: parent object of the frame, holds all of the walls etc. as children
     * linearOffset: the box collider for the frame which determines its size
     * wallMask: the mask for visual walls, used to determine if a wall already exists or not
     */
    [SerializeField] float wallOffset;//percent of distance the wall is between the center of the frame and the edge of the frame
                                      //I could have done it by distance but for some reason I couldn't figure out how???

    //Called when new room frame is placed
    void Start()
    {
        gameObject.GetComponent<Renderer>().enabled = false;
        GenerateWalls(transform.gameObject);
        FindNeighbors();
        parObj.name = $"Room ({parObj.transform.position.x/6}, {parObj.transform.position.y/6}, {parObj.transform.position.z/6})";

    }
    
    void GenerateWalls(GameObject obj)//generates empty wall parents around a room on all sides except those adjacent to other rooms
    {

        for (var i = 0; i<= 3; i++) {
            Quaternion rotApplied = Quaternion.Euler(0, 90f * i, 0);//adds 90 degrees each iteration
            Quaternion rot = obj.transform.localRotation;//rotation of frame, applied to walls
            Vector3 framePos = obj.transform.position;//position of frame

            Vector3 offset = new(0,0,linearOffset.size.z * 0.5f);//offset from the center of the frame
            offset = rotApplied * offset * wallOffset;
            offset += framePos;
            GameObject newObj = Instantiate(blank, offset, rotApplied * rot, obj.transform.parent);
            newObj.name = $"{blank.name}{(NSEW)i}";//renames walls based on direc1tion they are facing
        }
    }
    private void FindNeighbors()//finds if there are neighboring frames
    {
        float sizeX = linearOffset.size.x * 0.5f + 2f;
        
        for (int i = 0; i<=3; i++)
        {
            //Debug.DrawRay(transform.position, Quaternion.AngleAxis(90f * i, Vector3.up) * Vector3.forward * sizeX, Color.red, 5f);
            if (Physics.Raycast(transform.position, Quaternion.AngleAxis(90f * i, Vector3.up) * Vector3.forward * sizeX, out RaycastHit hit, sizeX, wallMask))//shoots ray, rotates by 90 degrees per iteration
            {
                Debug.Log($"{Quaternion.AngleAxis(90f * i, Vector3.up) * Vector3.forward * sizeX} {90 * i}");
                Debug.Log($"Hit object {hit.collider}@{hit.transform.position} from {transform.position} with run index {i}", hit.transform.gameObject);
                Debug.Log("Click", hit.transform.gameObject);
                Debug.DrawLine(transform.position, hit.point, Color.red, 5f);
                Debug.Break();
            }
        }
    }
    private enum NSEW//pos Z = north, pos X = East
    {
        North, East, South, West
    }
}
swift crag
#

please put that in a pastebin site

#

it's very long

edgy fox
#

!code

eternal falconBOT
swift crag
sly wasp
#

thank youuuuuuuu

bronze yacht
#

Hello Guys
I Have a noob problem i imported a project into unity and when i try to open code from the project it doesn't seem to know where to open it, it does open Visual Studio so i have the right editor chosen.

swift crag
#

I don't know what "doesn't seem to know where to open it" means

rocky canyon
#

i can only wish you luck mate @edgy fox as idk, but im gonna guess its ur system..
if u hand place the piece in front of a gameobject and then use a normal raycast method on that object. like put it on a gameobject and raycast forward with a mouse click or something) just to ensure my raycasts are working.. and debug what it says, etc

sly wasp
rocky canyon
#

if a basic raycast works and detects that object the way it should. it'd be atleast a little knowledge you have

silver sierra
#

dumb shit: im instantiating a game object to clone it but for someeee reason when i clone it several times it goes like this:
cube (clone)
cube (clone) (clone)

swift crag
swift crag
#

it sounds like you're cloning the clone

bronze yacht
edgy fox
silver sierra
#

idk how i am tho im instantiating a game object

swift crag
rocky canyon
#

u should make a prefab and instantiate it.

#

not an actual object from the scene

edgy fox
#

the red line is the raycast, it is "hitting" the white and orange wall

swift crag
#

sounds like you aren't instantiating a prefab, yes

edgy fox
#

how do I convert an object with children into a prefab?

swift crag
#

Do the walls not have backfaces?

silver sierra
#

ohhhh hold up

#

i got it

swift crag
#

Rotate the view so I can actually see what it's hitting

edgy fox
#

it's not hitting anything

#

it's "hitting" the wall circled in green

silver sierra
thorn holly
#

so i have this script, basically it runs a fight seen. Is there a way to execute a method that does something, wait until the player selects one of three options, and then continues doing stuff?

rocky canyon
#

make it a prefab,
drag in that prefab into the script instead of teh gameobject from teh scene

rocky canyon
swift crag
edgy fox
silver sierra
# rocky canyon cool stuff πŸ‘

basically it was a script error, where i was calling and instantiating the game object weirdly but i changed how i did it once i spotted it

rocky canyon
#

if u can figure this out Fen you'll solve an issue he's been having for days i think lol

edgy fox
edgy fox
#

collapse?

swift crag
#

it's an option in the console to hide identical messages

#

it could bemaking it hard to tell if your'e getting multiple hits

edgy fox
#

oh yeah it's off

swift crag
#

although, you log i in there, so it would separate the messages out.

#

Show me the console after the code runs.

edgy fox
swift crag
#

is blank an EZWall prefab?

lone sable
#

Anyone know what as of late, VS Code doesn't want to auto complete unity stuff for me?

swift crag
eternal falconBOT
swift crag
#

should wake it up

lone sable
#

Already have.

swift crag
#

this is especially important if you were previously using the Visual Studio Code Editor package

#

are you using that package?

#

check in the package manager.

lone sable
#

Nope. I uninstalled all packages/extensions and reinstalled them all, still not working.

edgy fox
swift crag
edgy fox
#

when blank is clicked, it allows a wall to be placed

swift crag
#

okay, so EZWall exists in the scene from the start

edgy fox
#

and blank is a parent of the added walls

real merlin
#

is there any way to get the index of an array while you're doing a foreach loop ?

#

like the index it is in

swift crag
swift crag
#

i do wish we had Python's enumerate

edgy fox
#

1 room by 1 room size

tepid cove
#

its quite vague but right now i have a pitch black scene with no skybox and just use inside roomswith inside light, but i want to have lighting from the skybox of however you do it to get a lighting scene like this:

real merlin
tepid cove
tepid cove
# tepid cove

but direct lighting just flashbangs my whole scene and goes through walls

swift crag
rich adder
swift crag
#

Otherwise, every surface will reflect the skybox.

#

This is not a code problem.

swift crag
# edgy fox

I was wondering if the collider was getting stretched at some point.

#

Doesn't seem like it.

#

sanity check this by turning off the EZWall collider

real merlin
edgy fox
#

yeah that was a previous issue I had but adding a child 1x1x1 blank GameObject fixed scaling

swift crag
#
array[i];
#

this is no different from any other array!

real merlin
#

oh right i'm stupid

#

thank you very much

swift crag
edgy fox
tropic dirge
#

it took me 25 minutes to make a account for unity again

edgy fox
#

and yeah it does miss

swift crag
tropic dirge
#

because the emails they where sending wherent going to the correct gmail

edgy fox
#

yeah I have reverified that over and over again but I get that - literally every sign is pointing to it being not that collider

#

the only thing I can think of is that the raycasts are shooting from the center of the wrong room - the room that the wall is a child of, and then being translated somehow back to the room being placed

#

because if I add 4 walls, it shoots 4 rays out as if the room being placed had 4 walls

#

(the white line means there is a wall there but transparent so you can actually see into the room)

swift crag
#

that's because it's registering four hits

tepid cove
swift crag
#

that is useful information

swift crag
#

you generally don't use it for everything

tepid cove
#

when i add direct lighting

edgy fox
#

yeah and if I move one of the wallEZs' colliders, the raycasts from newRoom (not a term in the code, will use that term from now on as newRoom and oldRoom need to be distinctly communicated) are longer/shorter depending on how I move them

swift crag
#

oh, I see: that ray is shooting up and left

#

I was interpreting it as going down and right

edgy fox
#

it extends straight left/right/forward/back

#

it's a grid system

#

so far at least

real merlin
swift crag
#

oh, wrong name!

#

array.Length

real merlin
#

ooh

swift crag
#

Count is an extension method from LINQ that's used to count any enumerable

edgy fox
#

quick little diagram

real merlin
#

what's linq ?

edgy fox
#

and there are no vertical components to the raycasts at all

swift crag
#

System.LINQ provides extension methods to do various things with enumerables, like ordering and summing them

swift crag
edgy fox
#

with which direction is up changing depending on my mood

#

but yeah I think you understand how it all is

swift crag
#

(also, instead of raycasting, I would just remember which sides have walls assigned already)

edgy fox
#

that would work

#

and then I would just need to detect which sides already have rooms

swift crag
edgy fox
swift crag
#

is it attached to the room frame?

edgy fox
#

oh yeah

#

it is

#

with room being a blank GameObject with my custom coords in the title and frame having the scripts

#

and WallEZHolder being the blank GameObject that holds WallEZ

languid spire
rocky canyon
#

Cardinal Directions are great when working on top down type stuff

edgy fox
#

yeah and for right now my game is essentially a glorified top down game

rocky canyon
#

another thing is to keep ur eye on scaling.. if ur rooms/walls are child objects and they're all using primative colliders like a box collider or what not.. it could be that certain positions or rotations might wig out the actual fitment of those colliders

meager raptor
#
    public float minY = 20f;
    public float maxY = 120f;
    public Vector2 mapLimit;
void ClampPosition() {
    newPosition.x = Mathf.Clamp(newPosition.x, -mapLimit.x, mapLimit.x);
    newPosition.z = Mathf.Clamp(newPosition.z, -mapLimit.y, mapLimit.y);
    newPosition.y = Mathf.Clamp(newPosition.y, minY, maxY);
}```
trying to set camera limits, so it doesn't go off the map etc
problem: newPosition.x and newPosition.z works (WASD keys) , but not newPosition.y (scrollwheel), why is this?
rocky canyon
#

i tend to try to use 3d modelled colliders with scales of 1:1:1 to keep everything as proper as possible.. just a little helpful tip

edgy fox
rocky canyon
#

just making sure, lol im just trying to cover all bases

edgy fox
#

yeah no worries lol

#

earlier I had a funny glitch where you could make WallEZ repeatedly bigger by clicking on a wall repeatedly which was fun

rocky canyon
#

πŸ˜„ not a bug, a feature

edgy fox
#

artist's recreation

rocky canyon
#

ship it

thorn holly
#

my cursor is stuck as a vertical arrow in unity, does anyone know whats going on?

edgy fox
#

but in seriousness, just using a neighbor finder that finds rooms instead of walls and finding the NSEW of the walls will be helpful because then I just need to find the neighboring rooms (code already written) and see if for example the room is to the west if that room has an eastern wall

thorn holly
#

i havent saved in a while so id rather not close out of unity and reopen it

edgy fox
#

save and then close and reopen

thorn holly
#

well how do i save if my cursor is stuck like a vertical arrow

edgy fox
#

ctrl

thorn holly
#

ah

edgy fox
#

ctrl s

swift crag
#

or by just clicking File -> Save Scene anyway

swift crag
#

so, one 4-walled room, then several 0-walled rooms

#

do they all wind up getting four hits on the walls?

edgy fox
#

yeah all adjacent rooms do

lone sable
swift crag
thorn holly
#

didnt work, thats quite a bit of progress gone

swift crag
#

it's completing everything that the static analyzer is actually aware of

thorn holly
#

thanks unity, for having a seizure

swift crag
#

because it doesn't matter if the cursor looks funny

#

that doesn't stop you from doing things

thorn holly
#

it must have been

swift crag
edgy fox
#

and if multiple rooms with walls are adjacent to the placed room itll still register

#

this setup for example triggered 12 times

#

4 for each of the 3 adjacent room

#

which really backs up my hypothesis the for loop runs for each of the adjacent rooms rather than for the room itself

swift crag
#

I think you're instantiating something incorrectly.

edgy fox
#

wait I lied it only generated 7

#

I do too

swift crag
#

so you placed 3 rooms and gave them 4 walls each

#

then you cleared your console and placed the room in the middle, and that caused 7 hits?

#

you should make sure you weren't just seeing old hits

tropic dirge
#

see yall in another few months

edgy fox
#

I miscounted - 4 hits

tropic dirge
#

unity didnt want to work so im gonna be back later

edgy fox
#

so it is still maxing out at 4 which makes sense as the for loop runs 4 times

#

I had 12 messages but each of the 4 times it happened I have 3 messages per hit

swift crag
#

well, that is way more than there should be

#

ah, I see what you mean

#

3 log entries

#

Are all four hits from the same room's walls, or do they vary?

native seal
#

is there any difference between doing it either way?

swift crag
#

the latter would require you to add [field : SerializeField] to each of the three properties so that they appear in the inspector

native seal
#

oh yea true, other than that?

swift crag
#

I generally prefer the former. It's less annoying if you want to rename or change how DamageBonus works

#

If you decide it should be something other than just a getter for a field, then you have to take care to migrate the serialized data over

#

with [FormerlySerializedAs]

native seal
#

how so?

#

oh since it will mess my items up

swift crag
#

the property will have been serialized as something like field_damageBonus by Unity

#

i forget the exact name it uses

edgy fox
swift crag
#

"Hit object ..."

#

that will highlight whatever you hit

edgy fox
#

only in this specific case though

#

it's weird

swift crag
#

Then the object doesn't exist anymore.

#

I wonder if your wall-attaching code is doing something bad here.

edgy fox
#

That's what I thought, but there is no code to destroy an object

swift crag
#

Perhaps the new rooms are winding up with walls that are instantly destroyed

#

or that are otherwise moved or made irrelevant

edgy fox
#

no object with the proper layerMask to intercept the raycast is created or destroyed

#

the hit coords

queen adder
#

What is the code to detect when the image moves???

#

I don't remember what code it was

shrewd swift
#

is there a faster way to generate a random boolean rather that using a Random.Range ?

ivory bobcat
swift crag
swift crag
#

that might be slightly off because Random.value goes from 0 to 1 inclusively

#

(annoyingly)

ivory bobcat
#

They'll never notice UnityChanwow

thorn holly
#

I have this code here:

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("Space Pressed");
            movePlayer();
        }
    }

    IEnumerator movePlayer()
    {
        selectedPosition = currentPosition;
        Debug.Log("selected position:" + selectedPosition);
        Debug.Log("current position:" + currentPosition);
        yield return new WaitUntil(() => selectedPosition != currentPosition);
        currentPosition = (SpacePosition)selectedPosition;
        player.position = new Vector3(0.5f + ((((int)currentPosition) - 1) * 2), transform.position.y, transform.position.z);
    }

For some reason, the second and third debug logs aren't running, indicating that the IEnumerator isn't running. The first debug log, however, does run, so it is registering that I pressed space.

ivory bobcat
#

Start Coroutine

queen adder
thorn holly
#

oh, i thought i could just run it like a method

ivory bobcat
rare basin
#

it's a coroutine

thorn holly
#

fair enough

rocky canyon
#
    void Start()
    {
        // Call the Coroutine using StartCoroutine
        StartCoroutine(YourCoroutine());
    }

    IEnumerator YourCoroutine()
    {```
swift crag
#

if you run a method that returns IEnumerator, it will execute everything up to the first yield

#

then it'll stop and return an IEnumerator

#

if you discard that return value, nothing more will happen

rocky canyon
#

like when an unwanted kid shows their parents their trophies

thorn holly
#

ah

#

thanks

rocky canyon
#

it can work just like a normal method tho

rocky canyon
# edgy fox

πŸ˜„ being a game developer ends up in some crazy search history

#

i feel im obligated to tell anyone that see's it.. "hey, im a game developer btw"

edgy fox
rocky canyon
#

i mean, it doubles as a comment when u read the script

edgy fox
#

yeah ofc

#

thats interesting

rocky canyon
#

tbf these variables were confusing to me at first.. and then i got the Min and Max flipped around

queen adder
#

I have another question, is it possible to change the texture of a block with a script?

rocky canyon
#

easier to assign a new material using the new texture

#

if you try to change the texture i believe you'll have to copy the material the block is using, change the texture on the copy and assign the copy to the material used

queen adder
rocky canyon
#

erm.. πŸ€” interesting. care to elaborate a bit? still a bit confused what you mean by when it moves

#

like a sprite? like animation?

queen adder
#

I would like to know if there is any code to change the texture or something like that

#

It doesn't work for me with event triggers because it gets bugged and that's why I decided to use codes

rich adder
#

event triggers only works if you put a 3D physics raycaster on the camera

#

otherwise its meant for UI / Canvas

rocky canyon
#

if(thingIsMoving){//use one texture}else{//use another texture}

#

not sure if ur using a rigidbody to move the thing, but whatever ur doing theres a way to tell if its moving.. just use an if statement

#

where you pass in w/e material u want to the ChangeMaterial() method..

queen adder
#

Thanks you!!

#

I really appreciate you for making example code

rocky canyon
#

if ur just moving the object with the mouse u can probably write ur own method that gets the last position and the new position in each frame

#

if they have changed its moving.. if not its not..

 private Vector3 lastPosition;

    void Start()
    {
        lastPosition = transform.position;
    }

    void Update()
    {
        // Get the current position
        Vector3 currentPosition = transform.position;

        // Check if the position has changed
        if (currentPosition != lastPosition)
        {
            // Object is moving, change texture to movingMaterial
            ChangeTexture(movingMaterial);
        }
        else
        {
            // Object is not moving, change texture to idleMaterial
            ChangeTexture(idleMaterial);
        }

        // Update lastPosition for the next frame
        lastPosition = currentPosition;
    }```
swift crag
#

sneaky one!

warm condor
#

hey, do you guys know what this error is?

polar acorn
native seal
#

would it be a good idea to use a dictionary for an item equipment system? (equipped items on the player, stats, etc) if not how should I handle it?

warm condor
#

is it a problem in unity or in my code?

polar acorn
rich adder
thorn holly
#

is there a way to add a courotine to a delegate in the same way you would add a method?

warm condor
#

hmmm, I tried to double click on the error and it seems that it is complaining on this line
isJumpSliding = timer.startTimer(jumpSlidingValue);

#

over here I am accessing a method in a c# script

warm condor
#

how? I don't understand what null is?

rich adder
warm condor
#

yea

rich adder
#

so it means the computer doesn't know which timer you want to run startTimer from, therefore nothing is there, hence Null

#

make timer not null

#

assign it

warm condor
#

you mean like this?

modest dust
#

That's declaring a variable

#

Assign an instance of that class to it

#

Timer timer = new Timer();

warm condor
#

ohhhhh ok I see

north kiln
# warm condor yea

The link is longer than one page, it's a whole damn resource that explains the concept from top to bottom

rich adder
meager raptor
#
UnityEditor.EditorApplication:Internal_CallDelayFunctions ()```

what is this error? google tells me to reset all layouts, clicked that and doesn't work, what's going ?
error appeared when i created a new scene
swift crag
#

I see that every time I start my editor. I should probably reset my layout..

meager raptor
modest dust
meager raptor
rich adder
modest dust
#

He was probably confused because of value / reference type differences

warm condor
modest dust
#

structs and other value type fields get initialized with their default constructor so they're ready to be used

swift crag
#

you are not allowed to directly construct a monobehaviour

modest dust
#

default value for classes is null

rich adder
swift crag
#

instead, you tell Unity to add a component to a game object. you can then store the reference it returns.

rich adder
#

so unlike regular C# class you don't need to new() an instance and use either a serialized field or the GetComponent method

swift crag
rich adder
swift crag
#

Unity just forbids a MonoBehaviour from existing without being attached to a game object

#

hence why you have to ask it to create components for you

rich adder
#

yeah thats what I kinda meant, the instance is made by unity by being attached to gameobject

thorn holly
#

huh

#

digi was right

#

once you know how a delegate works, you wont know how you lived without it

swift crag
#

delegate types open up higher-order programming

#

yum

warm condor
rich adder
#

Observer pattern I think is the technical term no?

rich adder
thorn holly
rich adder
#

or better to just Serialize the field in the inspector with public or [SerializeField] and assign by drag and drop @warm condor

swift crag
#

It is preferable to just get a reference to the component itself.

#
[SerializeField] MyComponentType target;
#

drag something into that Target field in the inspector

#

done

warm condor
#

oh I see, and MyComonentType should be what? the game object or the script?

rich adder
#

the script is the type

north kiln
#

The script type. Don't reference things via GameObject unless you only want to perform GameObject functions

warm condor
#

it seems that it doesn't recodnise the compnent type tho
[SerializeField] Script timer;

rich adder
#

why did you write script, I guess you took "the script" too literal

north kiln
#

do you have a type called Script?

warm condor
#

i mean idk what to put there so I just wrote script

rich adder
#

you declared it as such

#

you already have that part

#

all you need to add is the [SerializeField] so you can assign it in the inspector as said

modest dust
#

Taking a C# course followed by !learn would be probably a better solution to all of this

eternal falconBOT
#

:teacher: Unity Learn β†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

rich adder
#

yeah probably

#

best

rocky canyon
warm condor
#

yea your right. I am ne wto c# and unity in general and I have been leanring it while making the game because I already have programing experience in college.

#

oh and btw I have fixed the problem so thanks for that

swift crag
#

deactivating the walls before destroying them ensured they were gone in time

rocky canyon
#

epic!, glad u got it worked out, i was starting to feel bad for the guy lol

rich adder
swift crag
#

I was a little surprised that it worked, though, since the offending logic ran in the Start method of the instantiated room

rocky canyon
swift crag
#

the clue was that clicking on the logs didn't take you to a game object

#

even though the hit wall was included as context

rocky canyon
#

bc it didnt exist! πŸ€¦β€β™‚οΈ

swift crag
#

(any longer (: )

warm condor
rocky canyon
#

clever debugging πŸ‘

#

i overlooked that fen

#

i knew u'd boss it

rich adder
swift crag
#

(Python has type hints, but those are optional)

rich adder
#

I suppose you still have classes and all that like js but you need typescript for similiarity

north kiln
rocky canyon
#

vscommunity can be set up to have type hints

#

helpful to me so i dnt have to peek definitions all the time

rich adder
#

its on by default no ? I was trying to turn off but ended up just loving it

rich adder
#

makes things a bit verbose to look at but you get used to it

swift crag
#

zap

#

indeed

#

context is important (:

rocky canyon
#

thats why i suggested a blank scene with a hand placed wall..

#

i knew the raycast stuff didnt seem broken

swift crag
#

The red herring was the belief that the raycast was hitting the existing wall

north kiln
swift crag
#

which murders the children, yes

rocky canyon
#

i think so yea

north kiln
#

in a completely different script that I never saw

#

just so fucking dumb

swift crag
#

the plot twist was the instantiation of the existing room

rocky canyon
#

important thing being it works now.. πŸ˜…

north kiln
#

plot twist was that there was this entire other piece of code instantiating and destroying walls that was never mentioned

swift crag
#

I've done that a few times, but generally only to make recursive prefabs that create the child copies before modifying themselves at all

rocky canyon
#

ill have to remember the manage my destroyed objects better

#

so i dont run into a similar issue

swift crag
rocky canyon
#

true true, but when you destroy() an object it doesnt actually get destroyed until the end of that frame correct?

#

thats just something i need to watch out for (on my own projects)

rich adder
#

iirc its marked for cleanup until GC comes in no?

swift crag
#

Correct.

swift crag
#

You're thinking of C# objects.

rich adder
#

ahh ok

swift crag
#

we're talking about UnityEngine.Objects

rich adder
#

gotcha mb for butting in πŸ˜“

rocky canyon
#

you good.. we're a community πŸ™‚

meager raptor
#

noob question but how do i drag the text (like there's a box around it so i can move it about)?

rich adder
#

the unity lifecycle of objects is def something I should learn more πŸ˜“

swift crag
#

you can't move things around in the game view

#

switch to the scene view

rich adder
#

also might want to toggle 2D

meager raptor
rich adder
#

click your text obj in hierarchy and press F

meager raptor
rocky canyon
#

cant think of its name

rich adder
#

Rect Tool iirc

rocky canyon
#

the Rect tool yup

#

just had to watch the clip myself 🀣

rich adder
#

to many times in my earlier days "WHERE ARE MY ARROW GIZMOS"

#

oh wait Im in Rect tool mode

swift crag
#

It’s available when editing something with a RectTransform on it

#

I mostly use it to make it easier to see where the bounds of the selected object are. They can get lost in complicated UIs

rocky canyon
#

u can actually use it for anything πŸ˜„

#

i use it to offset scale my objects sometimes

#

OP tricks

rich adder
north kiln
swift crag
#

Oh right. It works for some other components as well

rocky canyon
#

lol, i wanted to try out pastels for a bit

rich adder
swift crag
#

It’ll leave you handle-less when you select a light

#

You can change a frightening number of colors in the settings

rocky canyon
north kiln
swift crag
#

Way too many colors

rich adder
#

Oh wow I thought you can only change playmode tint, I shouldve checked them

#

thanks!

rocky canyon
#

nah, u can go down a rabbit hole..

faint osprey
#
{
    public GameObject leverUnswitched;
    public GameObject leverSwitched;

    public bool hasActivated = false;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerStay2D(Collider2D collision)
    {
        if (Input.GetKeyDown(KeyCode.E) && hasActivated == false)
        {
            Debug.Log("working");
            hasActivated = true;
            leverSwitched.transform.position = new Vector3(0, 0, 1);
            leverUnswitched.transform.position = new Vector3(0, 0, -5);
        }
    }
}``` why is this not modifying my transform.position for both variables
#

the debug.log is being called

faint osprey
polar acorn
faint osprey
#

no i thought if they had transform it wouldnt matter

swift crag
#

a CharacterController would interfere

polar acorn
faint osprey
polar acorn
faint osprey
#

ive got it working now

#

however its really janky

#

like sometimes i press e and it does nothing

#

and then just magically works one time

polar acorn
faint osprey
#

i thought it ran every frame your in the collider

rocky canyon
#

no fixedupdate (default settings) runs 50 fps

polar acorn
faint osprey
#

it says every frame

polar acorn
#

While input checks on frames

rocky canyon
#

means the method is ran only once for each physics frame that runs im sure

tall delta
rocky canyon
#

as opposed to multiple times per

faint osprey
rocky canyon
#

put a debug in the update and one in the fixed update.. you'll see how differently they are

clever edge
#

yo can you have rigidbody2D velocity instantly accelerate instead of slowly

rocky canyon
rocky canyon
#

could also just set the velocity manually..

supple needle
#

I have a problem with my vehicle's steering wheel, i can get it to rotate back to its original position after turning for some reason

eternal falconBOT
rocky canyon
#

theres no code to turn it back..

clever edge
rocky canyon
#

if ur not pressing a left or right nothing happens

#

how would it rotate back when theres no code to run?

supple needle
#

Yea ik but what should i do ive tried a lot

rare basin
#

Make a logic to turn it back

supple needle
rocky canyon
#

u can add teh rotation after the if statement... and just change it back in the else statement

true pasture
#

I feel like theres a better way to do this (this doesnt even work) I'm just trying to see if the object I clicked has stats

tall delta
supple needle
rocky canyon
#

something like that

#

set the rotation to be facing forward or w/e then outside the if u can just use whatever rotation you use

supple needle
#

I use the GetAxis Horizontal thing, so i just need to set it to rotation(0,0,0) right?

rocky canyon
#
      // Get horizontal input
        float horizontalInput = Input.GetAxis("Horizontal");

        if (Mathf.Abs(horizontalInput) > 0.1f)
        {
            // Set the rotation based on input
            RotateSteeringWheel(horizontalInput);
        }
        else
        {
            // No horizontal input, set the rotation back to zero
            SetRotationToZero();
        }```
#

could do this..

supple needle
#

Woah, nice

#

Thanks ill have a look!

rocky canyon
# supple needle Thanks ill have a look!

i was thinking more like this tho ```cs
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");

if (Mathf.Abs(horizontalInput) > 0.1f)
{
    desiredRotation = CalculateRotation(horizontalInput);
}
else
{
    desiredRotation = 0f;
}

RotateSteeringWheel(desiredRotation);

}

#

so the steering wheel always rotating after the if/else statement.. but its the if/else statement that would set w/e rotation u want

supple needle
#

Im getting confused

rocky canyon
#

this will always run

supple needle
#

Ohh gotcha

rocky canyon
#

the if statement just sets what desiredRotation would be

true pasture
supple needle
#

Yayaya i understand

rocky canyon
#

still functions exactly like the main unity camera (b/c thats what it is)

rocky canyon
#
if(hit.collider.TryGetComponent(out MyScript myScriptReference))
{
   myScriptReference.DoFunction();
}``` ```cs
MyScript myScriptReference = hit.collider.GetComponent<MyScript>();

if (myScriptReference != null)
{
     myScriptReference.DoFunction();
}```
#

both of these do the same thing

#

you can Debug.Log(yourReference); to make sure its getting assigned (or not)

young anvil
#

where to begin learning?

polar acorn
eternal falconBOT
#

:teacher: Unity Learn β†—

Over 750 hours of free live and on-demand learning content for all levels of experience!

edgy fox
#

how many children would Room (0, 1, 0) have? Would it be 5 or would the children of the children such as WallEZholder(clone) be considered children as well?

#

like if I do transform.GetChild(2) would I get roof or BlankEast

#

ah its the former

rocky canyon
#

did u debug it?

#

thats how id find out real quick

edgy fox
#

Instantiate(wall, hit.transform.position, Quaternion.Euler(new Vector3(0, hit.transform.eulerAngles.y + 180, 0)), transform.Find($"Blank{(NSEW)i}"));

why does this code not make the wall a child of Blank{cardinalDirection} - if I debug log it transform.Find($"Blank{(NSEW)i}")); returns null

#

yeah debug logged it to find out which one it was

#

nvm I'm dumb, the transform is the fram's transform

#

not Room's transform

rocky canyon
#

Rubber πŸ¦†

edgy fox
#

still doesn't work

#

Debug Log still returns the child obj though

#

but now it just doesn't instantiate anything

polar acorn
#

Store the result of instantiate in a variable. If you pass that object to the second parameter of debug.log it'll highlight that object in the hierarchy when you click the log

#

See if that object is where you expect it to be

edgy fox
#

huh it doesnt highlight anything

#

||deja vu||

polar acorn
#

Then it's probably destroyed between the time you spawn it and click on the log

edgy fox
#

yeah

#

oh I know what the issue is

#

all children are killed and remade fresh when a new room is made

#

and this runs the same frame they're destroyed before new ones are made

#

is there a way to cache a command to execute next frame

acoustic violet
#

im not sure set it to an instance of an object

rich adder
polar acorn