#💻┃code-beginner
1 messages · Page 336 of 1
I can t find the function. It dosen t show up when i type it.
You don't find it, you just type it out in your script (and if it doesn't auto-complete then configure your IDE as shown below)
Same deal as with Update or Awake
!ide
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
configure your IDE
i have it configured
well, I'm sure you can finish typing the rest of the method name yourself
is not really working
explain yourself
anyone knows where is the problem here?
i mean if i go over the gameobject with the cursor it dose nothing
at the end, that bit that is underlined in red
ok, what should it be doing? What code have you written?
you dont say xd, but i meant how to fix it
; before *
to check if it works i just use print"smh"
Read the error -> understand the error (probably google it) -> change what it wants
OH MY FREAKING GOD IM SO STUPID
this isn't valid code
Did you read the documentation?
yes
Show your gameobject
Is that all?
and the script
where is the script.
box colliders aren't for UI
UI scale should always be left at 1,1,1.. use the width/ height to size UI elements correctly
Ok but what should i do, i can t use that function on UI
Use one of the correct UI funtions
The button component has on hover events, or you can use IPointerEnter/ Exit.. etc
google -> unity UI how to detect mouse over
thanks
im trying with playerprefs it is okay???
i mean, when i hit the chests they are opening all the time
Whoop
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
I have literally shared it with that
no you have not, you dropped your code file into the chat
i downloaded my code from hastebin sorry if did it wrong
you are supossed to post the LINK to the paste site
oh ok xd
using UnityEngine;
using UnityEngine.EventSystems;
public class UIButton : MonoBehaviour, IPointerDownHandler
{
public void OnPointerDown(PointerEventData eventData)
{
Debug.Log("Clicked on " + gameObject.name);
}
}
``` when using the IPointer Handlers the Image Component acts as the collider..
the only thing you need is a `GraphicRaycaster` component on the Canvas GameObject
and to make sure `RaycastTarget` is ticked on the `Image` component
Is this possible? Where character is assigned through the inspector?
...
Character = JsonConvert.DeserializeObject<Character>(characterJSON);
You can use Scriptable Objects which are basically made for this
no I'm wondering if it's possible to overwrite an existing object with JsonConvert.DeserializeObject
Sure, why not?
But why overwrite something you assigned?
Why not just reassign through the inspector?
the json is coming from my server
You can overwrite data, yes. Would be weird if you could not
The only reason why it would not be possible is if the field you try to replace has the readonly keyword, or if the property you try to replace has the init keyword
Also, unrelated style note, private fields usually start with an underscore and use camelcase
I don't like starting all my variables with _ too annoying to type
I disagree but feel free to learn your own style
In your case I would confuse it with a property for example
OculusSDKManagerMini.GetOculusUserData(r => {
}, x = () => {});
im trying to do this lambda expression for Action (event) that has no parameters, and i get an error "The name 'x' does not exist in the current context"
the expression x = () => {} first assign x to lambda expression () => {} then returns x
Because what is x supposed to be?
This local variable is never assigned
if you didnt declare x, then ofc does not exist
Instead, remove x = and it should be fine as an Action like you mentioned
that's why attributes are CamelCase and properties are camelCase
Am I using that right?
Attributes? What do you think an attribute is if I may ask?
_ is just hard to reach on my keyboard lol
And properties should be pascal case
guess the correct name would be field 😛
Thought so
I believe technically public fields should be pascal case and private fields should have an underscore
belgian azerty kinda sucks lol
I'll switch to QWERTY when I buy a new keyboard an rework my entire codbase 😅
will you please stop with the style police. There is NO technical reason for coding conventions and nothing is 'should' there is only 'could'
Didn't read the conversation?
yes, I read it, and I'm sick and tired of reading this crap time and time again
A few messages up it was merely a suggestion after I helped Pasc, who chose to continue the conversation
Cool down a bit 😎
yeah I found it interesting, it's easy if everyone uses the same coding conventions
you are the one pontificating about how others 'should' be doing things, not me
If these things are not appreciated then I'm sure they can say that themselves instead of having somebody else point it out.
Also, surely you can notice it is a "suggestion" and not required? They can learn their own style. This was also pointed out.
Would it be good practice to create a class to hold an InputActionAsset? I've done like this and just wondering if it's something that could come and bite me later on-
!code, use a paste site please
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Like that?
yes, thanks
I use PascalCase for everything lol
The function is static so it can't reach "this"
my bad
make a parameterless constructor to do the same
I'm definitely a C# beginner. I'll hang out here for a while and see what I can learn.
My case tier list:
- PascalCase
- camelCase
- Pascal_Snake_Case
- snake_case
- thiscaseiforgotthenameofwhichisalllowercase
- kebab-case
- Pascal-Kebab-Case
- camel_Snake_Case
- camel-Kebab-Case
- TRAINCASE
Embeded monobehaviour class, I dont think that will work
Oops i meant to reply to this guy @burnt vapor
i think it does work, It creates the gameobject instance and attaches the script, it also loads the InputActionAsset and enables it as it should
Also AssetDatabase is Editor only, so that cannot be in Awake
Hmmm, so it wouldnt work if i built it?
no
A tier list? 🤔
how'd I do that so it'd work in a build?
you'd need to use Resources.Load
Sorry i didn't mean from A-F
I mean from 1 to (last nunber)
Since most would be F
Unless i do a Grey and do FS, FA, FB, FC, FE, and FF
Everything under snake_case is an F basically IMO
Okay! Will look into that
~~Uff, I moved my Steam Manager script from one game object to another and now I'm getting this error:
Steamworks.InteropHelp.TestIfAvailableClient () (at Assets/com.rlabrecque.steamworks.net/Runtime/InteropHelp.cs:34)
Steamworks.SteamUser.GetAuthTicketForWebApi (System.String pchIdentity) (at Assets/com.rlabrecque.steamworks.net/Runtime/autogen/isteamuser.cs:205)
InfiniteForestIdle.SteamLogin.SignInWithSteam () (at Assets/Scripts/SteamLogin.cs:45)
InfiniteForestIdle.SteamLogin.Awake () (at Assets/Scripts/SteamLogin.cs:31)```
No idea why or how it broke, anyone got a clue?
It was working perfectly for months, but after the move it broke~~
Nvm, version control saved my life, wonder what happend though!
Moved the it into a folder i named "Resources" but it cannot seem to find the as it logs out "Null"
private void Start()
{
actions = Resources.Load<InputActionAsset>("Inputs/MainControlls.inputactions");
Debug.Log(actions);
actions.Enable();
}
Don't include extensions when using resources
because you did not bother to read the Resources.load documentation
Yeah my bad-
Thanks!
I need help I have this error thats not linked to a script so Idk how to fix it
It says something was null. Is it from an asset or something you've got in the scene?
Does restarting Unity fix it?
Might just be unity itself, not sure if it's this error, it used to happen constantly a few months back
how can i get that for my public floats?
idk i made a mistake in my game and it broke something so I went to my last update asset ripped it and no matter what i have that error
no
write a custom inspector
no i always have this error
that makes no sense, explain exactly what you did
You'll need to explain what mistake it was and what you did to attempt to fix this mistake.
You can use the [Range] attribute, check this out : https://learn.unity.com/tutorial/attributes
[Range(x,x)]
I am having a probelm with vs code, it loads the highlighting correctly at first but few seconds later it loads some incorrect thing
does anyone know what is causing this or how tof ix it
why did it work yesterday though
at a guess, something has updated itself and you have lost the path to dotnet in your environment settings
vs code did an update and windows updated and it broke grammarly as well
so something happened
well there you go, why am I not surprised, thank you MS
I have a question, lets say we have two objects, a parent and a child object. Both have trigger colliders. The parent object has a script attached to it that has a OnTriggerEnter function. Will the OnTriggerEnter function be called, if something hits ONLY the child collider?
if it has a rigidbody it combines the two into a composite collider
only the parent has rigidbody
thast what im talkin about
oh okay
physics events get sent to the first/ closest (hierarchy) Rigidbody
How do you export a c# file as a zip?
Okay so, if I want the child colliders not to call the OnTriggerEnter function on the parent object, do I just attach a rigidbody to the child object?
If im gonna make a keypad lock in Maya. Should I make each individual key a separate model and then in Unity I parent then keys to the base and then code each button to have its own collider and script to which will then unlock the keypad if correct order is put in?
not sure offhand, never needed to do that. 
yes, each key should be a different mesh.. but it doesn't need to be a different model all together..
the Collection would act as the parent.. and each mesh would be a child object.. once imported into unity
Okay yeah, it seems to be working, which is nice. Thank you
uhh... hello?
Nws, can’t even remember what scuffed thing I did to need that
Oh so, even if multiple objects are in one model, Unity will still separate the meshes into their own object.
as long as they are different meshes in blender yes
I use maya but same thing I guess.
yea, i figure it will work the same
this is a code chanel, what's the code question?
Alright thx.
Also idk what you’re doing but individual colliders may not be necessary
should i put it somewhere else?
#💻┃unity-talk for general unity stuff
if its more specific than that.. there might be another channel
if it's not a code question, then, yes.. put it in the correct channel
looks like a question for #💻┃unity-talk though
it's still kinda broken, but less broken
it still loads correctly for the first fwe secnds and then breaks to this
How do I change the font in the inspector? Preferably for a single element or script
probably more trouble than its worth
u got two options in the settings
Suppose it were worth the trouble
but its global..
Does anyone have a tutorial by any chance how to make snap zones trigger an event. For example, like a drawer opening or a door.
snap zones ? whats that
For VR. So if I move an object over a certain spot, the second I let go, it will snap into that location.
ohh its VR specific, haven't worked on that fully yet :\
try asking #🥽┃virtual-reality
Kinda a dead chat ngl.
"I refuse to post there"
"Why is it dead over there???"
the perpetual cycle continues
I’m using unity btw
installing the default theme and uninstalling it while active fixed it somehow
first @atomic sinew 🔽
If your IDE is not autocompleting code
or underlining errors, please configure it.
Select one:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code
• JetBrains Rider
• Other/None
do not post photos
then #📖┃code-of-conduct and #854851968446365696
is low code coverage bad?
huh
make sure you Configure your code editor before doing code
Will do
Ok thx
Hi i want to create a Quiz game with a Json file. I watched brackey tutorials but i have an error with the Json question loading. is there someone who can help me ?
Unity JSONUtility doesn't support naked arrays
It must be wrapped in an object
what are naked arrays ? how can i fix it ?
(Aside from this) Is there any reason you’d use JSONUtility over newtonsoft?
Nope
You can use it to ensure your object can be serialized by Unity itself if that is of any interest
If you dont have a specific reason, please just use Newtonsoft
what's newtonsoft ?
I usually worked on Godot and JSON but i have a project that godot can't run well ( FMV )
and i make this project for training UI/Json with unity.
Newtonsoft is a much nicer system for reading and writing to json
alright thanks i'll check that 🙂
It has easy Unity support
You can just using newtonsoft.smthorother btw
System.Text.Json is even better but hard to implement in Unity due to lack of support
Unity has a newtonsoft package now
Oh they made it a package? What version is that?
should i install something or is it by default in unity ?
Its a package you need to download
Okay
Syntax is about the same between the two
Thanks you so much everyone ! 🙂
hi, got a question, have a timer (on a canvas) that runs through my different levels and stops at the last level's completion, then displays the final time on a separate end canvas
however, despite using debug.log to show that all the functions are running, the final time is not displayed
timer code: https://paste.ofcode.org/G4jFC8Ni7UA4pNzTjmGN6c (component of first canvas)
code to display timer: https://paste.ofcode.org/mtsTGpjfkhggNaFViTyvaN (component of end canvas)
TimeManager is a DDOL object that'll persist between scenes, but timerText likely isn't, so when you try to update that text in the next scene it's not going to exist any more
the timer does exist between the different scenes, the only issue is that once it stops, that final time isnt displayed
unless im not understanding what you're saying correctly
Right, because the text you're updating to display it is on the original scene. The object you've assigned to timerText in the inspector is going to be in the first scene. You'll update that text, but when you change scenes, that object no longer exists to view it
is it possible to set a timescale value for only 1 object, so that only this object will be affected by the timescale while other objects won't be affected?
An array as the root of the json
Instead of being wrapped in an object
As I said the fix is to wrap it with an object
Make a float on that object, and any time you use Time.deltaTime in code, also multiply your local timescale factor
fine, thank you
Unity's serializer is faster. But it has limitations
should i go back to the topic of the player respawn issue as to why the player can't move and the health doesn't go back to full?
ahhh right, so how would i go about ensuring that is displayed on the final canvas; calling on the finalised time?
It'd probably be better to have a script on the text object that pulls data from this object and updates itself
rather than having this object change the text on a referenced text
I think i notced one of the reasons why is that when the player dies and respawns, the gameobject of the player disappears in checkpoint script
Are the objects referenced by the checkpoint script destroyed
i like the background
this means you are probably destroying it
thank you
Hello,
Any idea of how to check if the mouse was hovering a UI Element ?
I tried using the pointerData but it doesn't work,
I also tried this method
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hitInfo)) {
Debug.Log("Hit object: " + hitInfo.transform);
if (hitInfo.transform == transform) {
Debug.Log("Hi");
}
}
but nothing happened also.
need a collider on the UI element first
I have one already
hmm.. well... it's not in don'tdestroyonexit and spawnsa. new player
Easiest way for UI is to use the PointerHandler interfaces
https://docs.unity3d.com/2019.1/Documentation/ScriptReference/EventSystems.IPointerEnterHandler.html
If the scene restarts, everything in the scene is destroyed and respawned
Does it need a colider too ?
well... it supposed to be like respawn new player when the player dies and respawns
No, as long as it has a UI element with "Raycast Target" checked
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/api/UnityEngine.EventSystems.IPointerEnterHandler.html for the newer docs (UI got pulled into its own package a while ago)
it just the player that respawns, along with the enemies
and yes -- UI raycasting is entirely separate from 3D/2D physics
So, is the player object destroyed?
do you need to restart the scene or just respawn the player
(although I think you can allow physics colliders to block ui raycasts, but that's a separate matter)
well... I think so since the new player object when it respawns have the word (clone) in it
just respawn the player. is respawning a scene a thing?
I have it as a game object,
it's like a item template for an inventory
So then your checkpoint script is likely not referencing the new object
You'll want to check the actual UI element, like Text or Image or whatever is actually drawn
They all have it by default
should i show the checkpoint script?
i think u could teleport that gameobject back rather than destroying and spawning a new one, then it would keep the reference
you need to have a UI component added to the game object. A game object by itself doesn't do anything.
Probably.
(even though it has a RectTransform and is on the UI layer)
Ok, I am gonna try
it's like trying to do a physics raycast against a game object with no components on it
So, nothing sets player and player2 other than dragging them in
so if the objects that used to be referenced are destroyed, it no longer has them to reference
it worked beforehand a long time ago but after getting help here, it no longer works. ´
dang what happened lol
so Now if I do a Raycast I should check if the hitInfo.transform == the image.transform?
anyone knows why this isnt working?
I would guess it's simply not running
Because you probably haven't created the conditions required for it to run
Do you have an collider for the bullet set to trigger?
im not sure hold up ill go check, i was just following a tutorial
Ok then you skipped something from the tutorial
You need a Rigidbody2D
And a Collider2D on both objects
And at least on of them needs to be a trigger
The Is Trigger needs to be checked
then... should i changed that into something else than gameobject?
Show us
No worries
what was the problem?-
well im not sure cuz im still talking but i THINK its that i didnt set it as "is trigger"
ill check the bullet rn
The other thing probably shouldn't be a trigger
Just the bullet
But you told us "both checked" before lol
yeah i meant this
😭
Oh you hadnt activated the collider
AGREED
No it was enabled
STOP BULLING MEEEE 😭
But that's not what matters
has anyone else had objects become invisible in the scene view but visible ingame
Also if this is a screenshot from your project you're using the wrong Colliders
That's a 3D Collider
its not i took it from thicc's SS
Probably just not in the right place
#💻┃code-beginner message this is the code
Also not a code question
where should i put it
i think you should teleport the player gameobject to the respawn position rather than destroying and creating a new one
Maybe I'm just tired, but why wont this work?
Transform trans = camera;
trans.rotation = Quaternion.Euler(0, cameraCinemachine.m_XAxis.Value + 180, 0); //Turns the -180 - 180 range into 0 - 360
cameraMoveDelta = trans.TransformDirection(new Vector3(movementInput.x, 0, movementInput.y));
im not sure how to add instantiated objects into the editor
Define "won't work"?
but how do i do that?
Oh yeah sorry, was a little brief, but it only moves along the X axis, it should move along X and Z
hey im trying to make a 2d game where my 2d guy has a shield projected infront of him. but every time i start to move the shield drifts away from the character. is this because they both had ridgid bodies? how can i fix this
This code doesn't look like it would move anything. Just rotate
did you write the code or is it from a tutorial
My misstake again, it moves later using this,
moveVel = Vector2.Lerp(moveVel, cameraMoveDelta, Time.deltaTime * movementAcceleration);
cameraTarget.position += new Vector3(moveVel.x * movementSpeed, 0, moveVel.y * movementSpeed);
Vector2.Lerp will of course not work with Z
It will cut the Z off completely
it was way back then back at my school about game designing, my teacher helped me with this code and since i don't go there anymore, and it was months ago. idk why it's not working anymore after getting much help from here for some things
Makes so much sense now...
is lastCheckpoint the transform which you move your new player to currently
I... think so? but it's from player2d script, I don't know, it was a long time ago
assuming that script is attatched to the player
i think u wanna do transform.position = lastCheckpoint.position
just check what lastCheckpoint is
in plyaer2d script, the only part where it says lastCheckpoint is
public checkpoint lastCheckpoint;
it would be a good idea to know alittle about how your code works lol
https://gdl.space/wuzorifide.cs this is the player code
aren't i supposed to not be a gameobject?
what does that mean
i meant aren't i supposed to respawn the player as the same and now a new one? (even though it worked beforehand)
i think lastCheckpoint is another script
it's not another script
what is it then
i don't know, it's just a word right next to the public checkpoint in player2d script(checkpoint which is the script)
what is checkpoint
also if you dont know then you should learn what you are writing, if you are that is
i said it's the script
and how do variables work?
what is lastCheckpoint then
i said I don't know. it was a long time ago since last time i was in the checkpoint script. everything worked before but not anymore
we already see that in the code, thats not what they asked
lastCheckpoint is the variable name of type checkpoint which is also public
so what changed since then ?
things don't magically break on their own
i don't know. i don't know why it's not working anymore after all the help i got on other stuff
can you show whats in the inspector of the player2D script
well "other stuff" has affected this, you have to recall what might have changed.
and what is happening instead ?
Aside from the code, how do you get such fancy boxes around the text?
1 ` on each side
you can also do 3 for a code block, !code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Thanks!
I don't know! other stuff is when i got help from here with other scripts of why things are not working. how should i know why it's not working anymore?
I knew about that, just didn't know how to get a smaller box like you had-
then you should learn what your doing instead of doing it randomly
By tracing back the steps that got you here
that lastCheckpoint box is empty
i don't know why, i never even touched the checkpoint scripts when duringthese things
there is no way you got this far into developing this and still are confused how all this works..
yeah but since you have so much spaghetti, not surpised if changing something unrelated broke it
remember when I warned about keeping too many of the same functionality into multiple scripts
if you dont know how it works then u shouldnt be so certain that lastCheckpoint isnt a script
i think its gotta be
that is not the issue
HOW SHOULD I KNOW. How dare you!!!!!!!! Are you the developer or not? It is your responsibility to know
don't yell at me like that... I highly don't know why it's not working anymore after other things i got help from here. and I never even touched the checkpint script and other things for it during that
you reference lastCheckpoint 6 times in your checkpoint script so it probably is an issue lol
can you better explain what is happening instead of vs what you expect ?
when the player dies and respawn (a ne wplayer object) I'm not able to move anymore and the health bar is not back to full
So, what code moves the player, and what code refills the health bar
their newly instantated player is not being assigned in the inspector
that line is the only thing in player2d script with the word lastCheckpoint
but it wworked before tht player respawns and that i can move and the health bear is back to full
so i was saying that they should transform the current players position to the last checkpoint instead
you not remember when I said just resetting the player instead of creating new one would be easier 
so you dont break all your references
but i dont think they know how to tell where the last checkpoint is
isnt that the whole point of lastCheckpoint
This is a very very important lesson in what "Technical debt" means
Doing things fast early on means that now it takes half a dozen people several hours to change a health bar
All that technical debt has come due
the checkpoint script not the player2D script
I don't actually think the checkpoint script is the problem other than the fact that it's spawning a new player instead of just reusing the existing one
And honestly looking at all the Finds just makes me willing to write this whole thing off as unfixable
yeah used to be worse, can you imagine
hey found my handy work!
if (collision.TryGetComponent(out DoorInteraction d))
{
door = d;
}```
it worked before though
Right and your entire project is such an untenable mess of spaghetti I wouldn't be surprised if it's broken because today's date is odd instead of even
This is not going to be a simple fix. Everything's so interwoven it could be literally anywhere
So, my recommendation would be to try to simplify the code without changing the functionality, which will make it easier to find the problem
start consolidating and prob learning about single responsibility
Even just small things like caching Finds and GetComponents would go a long way to making the code more readable and thus, more debuggable
perhaps look up a tutorial on youtube which will show you how to make a 2D platformer respawn script
this will just cause the same issues
supergluing someone else's solution into this project is the last thing they want to do right now
lol i was just thinkin they should ditch that one tho
and since they dont know how to do their own
This is fixable, but not in its current state. So, the way to fix this is to start by cleaning things up. They won't actually address the problems, but they'll make it easier to find when they're done
Let's start with some light refactoring of the checkpoint script, starting with the fields. What do all of these variables do? What is the intention of keeping em around?
surely it should be as simple as detecting if the player has hit a trigger collider for the checkpoint postition and then setting the player to teleport there whenever they die
Right but every script is doing like nine things. So let's identify which things need to be here and what can be spun off
big issue is they barely understand their own code
In fact, this could take a while, so I'm starting up a thread
https://gdl.space/iwimeyesub.cs this is the code when takes damage
https://gdl.space/rodiduzobi.cs this is for health
https://gdl.space/hofehuquro.cs and this one is the player lost all lives, game over
https://gdl.space/oxonolanep.cs i think where GameObject go = Instantiate(player, transform.position, transform.rotation) as GameObject; is when the player spawns on the checkpoint object while i think
GameObject.FindGameObjectWithTag("Player 2").GetComponent<HitPoints>().ResetHitPoints();
GameObject.FindGameObjectWithTag("HealthUI2").GetComponent<PlayerHealthUI>().UpdateGraphics();
is when the health is back at full
The Great Refactoring
starcheck is for the checkpoint sprite when it is not passed. while the sprite starpassed is when you have passed the checkpoint which you can respawn from.
public bool checkpointReached; is to check is the checkpoint is passe dby any of the players or not
private SpriteRenderer checkpointSpriteRenderer; is so that the sprite can be changed to being passed
while i don't know about private GameObject _gameOverScreen; but it is used for if the player lost all lives down to 0 lives and when you die agian, it goes to a gameover screen
Let's move this into the thread.
ok
Is it preferred to use colliders or constant raycasts for ground checks?
I'm trying to instantiate gameobjects on each spot in a grid that there's one of the white hexagons but for some reason they're super offset. The green circle is around where it should be according to a function that debug logs mouse pos. Does anyone have any clue what could be going on?
Typically capsule cast or some shape cast is used, although entirely depends on your game. Colliders can work though I imagine it's more tedious to setup
Your code is just directly instantiating at x, y. Don't you need to convert those grid coordinates to world space?
It shouldn't matter because they should be converting the grid coordinates to world space, which they're not doing
This is not a data type problem
It has nothing to do with that
They need to convert grid coordinates into world space coordinates
That's exactly what the Grid component is for
I tried this and it worked, thanks!
private void FixedUpdate() { accelerationGain += 1 * Time.fixedDeltaTime; }
is this more acurate and frame rate independent than this?:
private void Update() { //accelerationGain += 1 * Time.deltaTime; }
?
yes
it's a bit unclear what "accelerationGain" is though
if it was velocity than absolutely yes.
dont worry I just need to be sure that is a value that increases by "x" per second
It really depends how it's being used whether it matters or not
And what your requirements are
but I do can share the script but I dont think is easy to understand where I want to go with. Disclaimer: I come from Arts, I use unreal (use only BPs) for few time but I decide to comeback to unity cause flexibility / freedom
The Notes at some comments are in Portuguese tho
I don't see where accelerationGain is used
it will be added to the base acceleration aka accelerationInMts
yeah it should go in FixedUpdate
btw thanks a lot for the help, I think I really never used this server, but I wasn't exepting help so fast
Hello, I hope you're doing well!
I have built a small dialogue system that uses 3 scripts to work with a string array and some booleans. Script 1 is responsible for typing out the text on screen (with typewriter effect), Script 2 is responsible for a lot of stuff but mainly checking OnTriggerEnter2D then checking for the if conditions responsible for increasing array index or disabling the text if the dialogue ends. Script 3 checks if the dialogue is on its last character and turns the canEndDialogue to true.
My problem is, in Script 2, the if conditions are all met and I've made sure by debugging but the code won't execute at all.
Script 1
https://gdl.space/erikafuner.cpp
Script 2
https://gdl.space/kutetewixe.cs
**Script 3 **
https://gdl.space/xojizosade.cpp
Why does my projectile collide with me even though I have multiple lines telling it not to...
in Script 2, the if conditions are all met and I've made sure by debugging but the code won't execute at all.
Which code won't execute? What debugging steps did you take?>
Doesn't look like your logs are printing typewriterScript.isDoneTyping which is one of the conditions you need
I've used Debug.Logs on every condition that needs to be met but I removed them for code simplicity sake
Prove it
Script 2 line 53
What is more likely to be true:
- you made a mistake
- if statements in C# don't work properly
if the code isn't running, your condition is false
Okay, I will write them again and post screenshots
THank you
Why does it keep colliding with me
I'm so confused
I tell it 3 times
I even put it in update
ignore layer
but it doesnt
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Am I missing something or are all relevant conditions met?
"Length" is the array length btw
I also just discovereed that pressing Return while the text in index "1" is being written keeps increasing the indexes until they are out of bound
This whole issue started because I wanted to disable pressing the Return UNTIL the dialogue has reached its absolute last letter
You call OnTypingComplete only if canEndDialogue is false, but the log shows it's true
Ok guys
I need someone
To
Ok
Ok h
Ok e
Ok l
Ok p
Read that
Read the red thing at the bottom
Idk how to fix
click the red thing
and then screenshot the console
Do not spam. Finish a thought. Then hit enter.
pls
Have you tried doing this to fix it?
😭
I think i see it, you need to wrap the Destroy() and the Physics.IgnoreLayerCollision inside the same scope (these {})
How?
@fluid glen
take a better screenshot
Do you see how they were responding to someone else? Not you
Take a screenshot (not a picture) and maybe someone will help
so my enemy AI will always have from 1-9 possible actions which are then weighted from most effective to least effective then i have a field called skill for enemy ai which is from 1-10 which determines how often they make highly effective actions
how can i create a calculation for the ai to pick an action from 1-9 based on skill while still being random?
this is the current enemyAI status
Give each option a weight, sum up all the weights, roll a number between 0 and that sum.
Then go through the list, if the value is less than the weight, do that option. Otherwise, subtract the weight from the roll and try the next. If you run out of weight, do the last option
what connecting would this have to the enemyAI skill field?
to separate low level npc battle from stronger npc ai
@robust pecan
Yupp?
Looks like you need another package downloaded? Not sure
What is the other error?
Ok, try to close Unity, delete the Library folder, and reopen unity. This will not affect your project assets or anything, but it will take a bit when you reopen unity as it regenerates the library
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
So I delete everything in library and library folder
Then re load unity back up
Just delete the folder, which will of course delete everything in it.
But yes
Make sure unity is CLOSED first
I want to make my item be rotatable to make the incoming inventory tetris not super boring. BUT when i rotate it and move even 1 pixel it just freaks out and disappears to some far away position. I cant rly find a fix online, the only questions i found are about the same problem in JavaScript lol. Gif that shows what i mean: https://i.imgur.com/IXu4Rk9.mp4
The relevant code:
public void OnMouseDown()
{
isDragging = true;
transform.rotation = Quaternion.identity;
GetComponent<Rigidbody2D>().isKinematic = true;
}
void Update()
{
if (isDragging && Input.GetKeyDown(KeyCode.R))
{
transform.Rotate(0, 0, 90);
}
if (isDragging == true)
{
Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
transform.Translate(mousePosition);
}
}
Should I click enter safe mode or ignore
Doesn't matter. That does mean the errors are still there though
Oh shit that’s a problem innit
Have you tried adding the positions onto the transform.position instead of using transform.Translate()?
Did you add the VisionOS module?
Thank you! I had to add an extra boolean named "canPressButton" and your comment helped me solve it
Not sure don’t think so.
Yh it’s the vision os that’s the problem
But I don’t want a vision pro app it’s meant to be oculus tho?
"transform.position = mousePosition;" (and removing the "- transform position from it) works 😄 idk why i did it like this... edit: probably some video that i copied 💀
thanks!
No worries!
@summer stump
Well, it looks like you have it as a build target or something? I have never done xr/vr so I'm not sure
Ok
Try open up the build panel and send a screenshot?
Ok
I'm trying to implement pathfinding but every time I run this the program freezes until the computer runs out of memory. I'm guessing there's an infinite loop but there shouldn't be.
https://gdl.space/wicomasufi.php
These variable names are really hard to follow. Though really if this isnt finishing instantly, its either an infinite loop or running way way too much logic.
Your best option here is to just attach the debugger and run it line by line on a very small sample
Oh I found the issue ok thanks
https://paste.ee/p/S0Bwb, i made this... is this what your specifying?
Is there something like [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] that acts for every scene instead of first only?
#💻┃code-beginner message
What is the reason why the object is created twice when I use the instantiate command?
show where and how you run instantiate
You are gonna be loading those scenes yourself, so you could really just use some event for this
It isn't. You're probably calling Instantiate twice
finally changed your profile picture, thats new
the formatting on this code.. wtf
Yes I started streaming a while back and my wife surprised me with a VTube rig for my birthday and I love it so I'm using it everywhere
You must be running this code twice
nice, looks good 👍
@atomic yew yeah this coroutine might be called twice,
hard to say without seeing the whole script
@rare basin sorry for the ping but i remade my enemy ai and haven't completed some certain things but i wanted your opinion
do you have 2 objects with this script?
i made a class called action containing the weight of the enemy possible action and what it does
then through the enemy ai used a List<> and did it like that
does it look workable at all?
it is work
it is work
There were 3 of them. Turning it off fixed it
thank you all. Thanks to you, I found the answer to the question I was looking for for 2 hours in 1 minute.
Thank you too, my friend, for your interest.
Where do I find information on how the Skinned Mesh Renderer works? I want to understand exactly what is being done with the armature transforms and shapekeys, and what info it is passing to the shader. Is there somewhere I can read the code for it? Can it be modified?
It just takes the weight painting on your rig and applies the corresponding positional modifications to the vertices in graphics memory. The shader then handles things as normal with the updated vertex positions
No you can't modify it
Hmm. I assume Blendshapes are applied first. I'm trying to figure out how I make a system to turn on blendshapes based on the camera angle.
Is it doing those positional changes in the vertex shader? Can that be edited there?
https://paste.ee/p/cBPPO, how could i implement the enemy ai skill into my function on line 70?
in the body
can someone explain the error here for me im confused the compiler error page didnt help
vector3 is 3 floats. what you wrote makes no sense
There is no body property
transform.position = transform.position ?
thx
what are you attempting to do with that line of code?
spawn a slash at the players position
the script is on the player so it should spawn there no?
Not there sadly
okay now explain what you thought that line of code was doing
Mind explaining what this means
Why is this a thing
what part of that line do you think has anything to do with spawning? i'm trying to figure out what you were doing with that line that had the error on it specifically
the script is on the player so i though it would use the players position
like wtf was going through your head when you wrote it because the entire line is basically nonsense
the instantiate would be after
oh you might have to do GetCinemachineComponent<CinemachineFramingTransposer>().
https://docs.unity3d.com/Packages/com.unity.cinemachine@2.3/api/Cinemachine.CinemachineFramingTransposer.html
Okay but
what is this
Like literally what are you trying to do here
and i'm not fucking asking about instantiate. i'm asking about the line of code with the error on it.
Yes that's it! Great!
this isnt helping ill try myself
didn't you hear, they were trying to spawn a slash on the player
we cannot correct your misunderstanding without knowing wtf you thought was happening on that line
your just flaming me
Listen, the line you've posted is pure, unadulterated nonsense. To the point that in order to actually help you we need to know what you were thinking when you wrote it so we can find out what went wrong and correct the misunderstanding
no, i'm trying to figure out what the actual fuck you thought that line of code was doing so that i can explain why that is not anywhere close to what it actually says
You have clearly missed something very basic, and unless you explain why you thought to write that we have no idea what
we can only assume by what we see
its fixed
that line makes no sense , maybe you thought it did something else. We wanted to know what
what was the fix?
ill just show you
One message removed from a suspended account.
layermask is not a single number
you are using layer indices, not the bitmask. serialize the LayerMask variable and assign it in the inspector
Layers 6 and 7 are NOT layermask 6 and 7
One message removed from a suspended account.
yes there we go, that makes more sense, at least 2 floats in constructor for v3
OMG
what
thank you thats better than pasting my own code back to me twice
Vector3 spawnPos = Player.transform.position;
spawnPos.z = transform.position.z;
ah was just writing that..
huh which if statement?
did you look?
thank you
......i kinda wanna know one last thing
how do i make the range not random
i tried RangeInt but it doesnt seem to work
dont use Random.Range
https://gyazo.com/ac754dae3c0215e0b312ac7aba078b3e does anyone know how I could make this for mobile where you have to hold the screen to rotate the gun instead it moving with the mouse ``` public Transform m_transform;
Vector2 direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - m_transform.position;
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; // angle it most rotatet o face the mouse
Quaternion rotation = Quaternion.AngleAxis(angle + 35, Vector3.forward);
m_transform.rotation = rotation;
what are you trying to do?
spawn a range of prefabs
you are using random, how do you not use random
by not using random but using something specific
but you said 'how do i make the range not random'
I removed the word random and it still didnt work
why would it
what do you want more from me
to go away and actually learn something
i want it to alternate between the 2 prefabs
instead of randomizing it
ok so you need to do 0, 1, 0, 1, 0, 1, 0
well why did you not say that first?
mb
yes, you also need to learn how to ask questions so that others can understand
sorry then
isnt that what SlashPrefab.Length does
why would .Length change in that code?
im not understanding
no you are not. Go and learn the basics of C# and coding
it gets how long the prefab array is
can you atleast tell me where i can learn unity C#
yes, and does the length of the prefab array change in your code?
so why would you say #💻┃code-beginner message
SlashPrefab.Length gets the length of the SlashPrefab array
ik that
And Random.Range gets you a random value in a range
mhm
because im a beginner like tf??
Listen, if you literally say the opposite of what you want, and we tell you how to do that thing, and then later you say that's not what you want, that's not on us
You'd want to store which index you used in a variable, and after using it, change that variable to the other one
that makes sense ill do that
Various ways to do it; here are some examples:
private int _attackIndex; // stores the value for incremental usage
private void SpawnSlash() {
// option 1:
_attackIndex++;
if (_attackIndex == SlashPrefabs.Length) {
_attackIndex = 0;
}
// option 2:
// https://docs.unity3d.com/ScriptReference/Mathf.Repeat.html
_attackIndex = (int)Mathf.Repeat(_attackIndex + 1, SlashPrefabs.Length);
// option 3:
// modulus; gives the remainder of the division: (_attackIndex + 1) / SlashPrefabs.Length
// so 0 / 5 -> 0, 1 / 5 -> 1, 2 / 5 -> 2, 12 / 5 -> 2, etc
// https://www.dotnetperls.com/modulo
_attackIndex = (_attackIndex + 1) % SlashPrefabs.Length;
// option 4:
// if you only have two, you can get fancy
// flips the first bit so it goes 1, 0, 1, 0
_attackIndex ^= 1;
// rest of code
}
Do whatever feels the easiest to you 👍
tysm this will help alot
Fancy!
Greetings my fellows, I am a total newbie using Vuforia (AR) and I was having this issue where, having an imageState that contains a Cube, for it to rotate as long as it's on the ARCamera POV, basically when it is "onTargetFound". But it's not working at all. I probably lack something or have something wrong which I have reviewed over and over but since I lack knowledge I am struggling to get it.
(The "cube" is the rectangle-like one)
The original idea was to make both the cube and cylinder rotate when BOTH where on the camera's POV, but I can't make it work with only one so let alone both.
Would appreciate if anyone could guide me to a better understanding.
I'm not familiar with Vuforia, but have you set the functions properly in the inspector?
in the OnTargetFound event, it looks like you've assigned the script but not the function being called
There is no function available to be selected, that's what weirds me out
did you drag the script itself rather than the object the script is on?
since it's a monobehaviour you'll need to target the instance of it, whatever GameObject your RotarControllerFound component is attached to
It indeed is a mono script, as stated in RotarControllerFound. But I don't quite get what you mean, are you implying the script RotarControllerFound has as many instances as gameobjects it is attached to?
on your ImageTarget GameObject you have a RotarControllerFound component, that's an instance of the class that your script defines - make sure that's what you're dragging into the UnityEvent inspector
it's possible to drag the script file from your assets folder instead, but it wont know what to do with that, so it wont show any functions on it
Thank you so much!! That was the issue. Now, I dragged the instance instead to the event inspector, and can now find the missing functions 🙂
how can i integrate my enemy ai, enemy skill into the choose action function in my enemy ai script
line 70-94
the better the enemy skill, the higher likely for a higher weighted action
what are you struggling to do exactly? you can just use the skill variable anywhere you want in this equation. This just depends really how you want the skill to affect what it can use. You probably just need to think about how it affects it, in terms of numbers first, before trying to make the code solution
i've been trying to think about how it would affect the numbers but i can't find a way to make like a 10 skill for an enemy calculate to be all that better than 1,2,3 etc
also i have another question
i'll ask after this
this is my first time ever making an ai for a custom battling game
first think about this purely in numbers. You have a skill level from 1-10. How much more likely should it be that someone picks the highest weighted ability, or 2nd highest, or any, based on these numbers.
A simple way could be scaling the weight relative to the average weight. Or even just doing exponential like new weight = (weight ^ skill)
All this really depends how much you want skill to matter
oh i get it
so when the weight is calculated, that weight is then changed based on the enemy skill whether it's good or not
hello Bawsi would you be interested in tutoring me in discord for 30 min on unity for 20 $ and Ill pay before we start Im trying to do something and didn't find tutorials on it
assuming i understood what you want, yea. Simplest way would be directly affecting the weights
no
here wait look at this...
aw man lol
p2w
this is the action script that calculates weight based on different variables
even if i changed the initial weight would it really effect anything?
it would still be sorted from 1-9 best actions
since these are (relatively) high values, then i take back the part about doing exponents on them. Any sort of multiplication should work
ok Bawsi you know the game among us you know when the player goes to tasks and then a small minigame opens and you play it and finish it I was trying to do that but didnt find turorial on it the only way I can do something like that is if I tell a script to change the scene and if the player wins go back to the old scene but the requirment is for the game to stay in the scene and the mini game to be in the same screen like among us
do you know any tuturial on that
yeah id end up dealing with big numbers with expo
sorry i didnt mean change the initial weight, i meant in that ChooseAction() function you can just do like
float newWeight = SomeScalingFactor(action.actionWeight);
or however you choose to scale it. Then you'd need to store these scaled weights as well temporarily
when you get the chance please answer me Bawsi
🤷♂️ dont know why you're asking me directly. what you wrote was barely a question, it was literally all one sentence. Look up additive scene loading and read the #854851968446365696 on how to properly ask a question
id learn about canvas and UI
yea also could just show some UI or do it via additive scenes.
alright so it scales the weight based on the enemies skill making higher weighted less and lower weighted higher then
for a lower skill^
should i come up with a scaling factor for each skill then?
that is a nightmare becuase all I know is how to code lol and ui is something very new to me
and Im fine with learning new things but I have a deadline and didnt expect not to find tuturiols on lol
but thanks
sorry that was for Frostyio
!code
(using this for myself)
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
If thats what you want to do then yea, i assumed skill lvl 1 would mean it wouldnt affect the values. Either way, there should be some skill level that basically doesnt touch the weights. Honestly im not even sure what to suggest for an equation, I imagine you could use something related to the average of all the total weights. Like if you have weights 20, 40, and 60. 20 would be seen as below average, 60 above average. Do what you want from there based on a formula
I'm encountering a weird error when i run my code. Does anyone know what this means and/or how to fix it? The game works just fine in Unity, so its only wonky like this when its being run.
Looks like a stack overflow somewhere in the web assembly code
Could be your code or the engine itself
unity makes it easy for you, and you'll have to learn it otherwise your life will be much harder
id probably make 5 not change anything, the average enemy
so i could figure that one out first
I will learn all of it just as I mentioned its just the deadline and me not being aware of the fact that theres no tutorials for it
for an among us type deal id make a new UI then have it become enabled whenever that mini game starts then make the UI start the mini game and run it
I'm trying to access the player 2d component to access the last check point reference (an object in the scene that was last reference) yet idk why it have a red underline there
does whatever GetPlayer returns have a public player2d variable?
also it generally helps to share the error
the GetPlayer method is in PlayerManager
PlayerComponents go = PlayerManager.instance.SpawnPlayer(1, PlayerManager.instance.GetPlayer(1).player2d.lastCheckPoint.transform.position);
does PlayerComponents have a public variable called player2d
okay so what does the error say
here, i'll give you a hint: take another look at the line you've written. then look at the PlayerComponents class and see if there's anything different
how does one fix this? from what I could find from forums, they suggest changing some settings to make them lower so WebGL can run the game, but it seems mine are already on the suggested fix's settings
oh.... come on!
everything is working now, but however... when I'm in a different scene, in a world when you select a stage and when i spawn in that stage scene and when i die and repsawn, it doesn't work
often has to do with infinite code loops
PlayerComponents go = PlayerManager.instance.SpawnPlayer(1, PlayerManager.instance.GetPlayer(1).player2D.lastCheckpoint.transform.position);
and it sent me over to this line of code
the only loop i have running is for background music, but it worked just fine on an earlier WebGL build
Hello guys, im very new in unity and c# aswell, sorry for bothering you guys. i wonder if anyone knows how to calculate the position offset from a angle, i tried polar coodinates, transformpoint, rotatearound, trigonometry in gereneral but everything i do result in wrong position.
Context:
this is a IK system that i want to do procedural animation combined with regular animations.
If i im broking some rule please let me now
https://gdl.space/totecuriki.cs
how to calculate the position offset from a angle
This is very vague, it's not clear what you're asking for exactly.
Also for sharing code: !code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
i want that the left hand follow the rotation of right hand like its child but just the rotation offset not in overall
the one you've got commented is wrong, it should be:
float x = r * Mathf.Cos(phi) * Mathf.Sin(theta);
float y = r * Mathf.Cos(theta);
float z = r * Mathf.Sin(phi) * Mathf.Sin(theta);
dunno where you got -0.31f from though
https://docs.unity3d.com/Manual/class-RotationConstraint.html
There's this class that's primarily for animation constraints
otherwise I suspect you'd want to use Quaternion.Inverse
the 0.31f was the temporarly fix for the r * Mathf.Cos(theta) because cos is never 0, so always he was return a offset
also didnt work i tried some combinations because im using camera local space so i thought this was the issue but isnt.
saddly i cant use constraints because i want just a offset and not the entirely transform. if i could, i use the parent constraint instead
i think i have to use matrix probaly but had the same effect
Not too sure the results you want, but when im confused with space relativity, I just work it out from world space
how can i multiply a number by another, where if it's multiplying against a low number it gets higher, if it's a high number it gets lower
for example if the number is 70 it gets lower when multiplied, or if it's 5 it gets higher when multiplied
i want to left hand follow the exactly same position that it are even with the right hand offset rotation.
I just transform the world position to camera position for the offset be the same whatever the world axis the camera are facing
so, find the offset of the right hand from the camera's position and just add it to the left hand's position
not the position offset its the rotation offse
what is the context?
your screenshot there says positionoffset
i need my lower skill enemyAI chance to use a lower weighted action to be raised while the higher weighted action to be lowered
making the worse move more likely, better move less likely
then the opposite for the better ones
yep, turn right hand rotation offset to left hand position offset. my code are little messy
May i introduce to you: division
i would rotate the hand, get the position offset from the origin (the camera in this case) then just add it to the left hand
i though too, but the result maybe dont be what he looking for
I assume you mean the hand rotates around the camera, but that is just positional displacement when you think about it
i think if i demonstrate it with ingame screenshot ull understand but its more moving the left hand moving arond the right hand, like its child only for this rotation offset
maybe a video would better
a lot can be solved by general vector addition using the origin
of course you can do it with matrix logics, but sometimes the easiest solution would suffice
i tried the matrix now and it does a lot of that i dont know, but i dont know other way to calculate a position with a angle and radius. i used the polar coordinates and was uunsuccessful
A bit hard to explain this one:
I have 3 classes: Character (not a MonoBehaviour), CharacterLogic (MB) and CharacterVisuals (MB)
CharacterLogic is on a gameobject and holds a reference to Character and CharacterVisuals
CharacterVisuals is on another gameobject and holds a reference to CharacterLogic
I also had a reference to Character on CharacterVisuals
I assigned it in the Awake function like this: this.Character = this.CharacterLogic.Character
Then after the CharacterLogic.Character got loaded, none of the values in CharacterVisuals.Character were updated?
Can you not reference objects like this? Where did I go wrong?
if my script extends a class from unity library
like dropdown (which is a class for dropdown UI in unityengine.UI)
if i declare new variables, will it shows on inspector? (public var ofc)
public class CustomDropDown : Dropdown
{
public GameObject arrow;
public Image currentSelectBg;
public Text currentSelectText;
public Transform generatedDropDown;
public RectTransform dropDownScrollContent;
}```
im fully confident that im not blind
ok this is absurd
the team has a custom script that has identical name to one of the class in unity library
and its using that library as well
if it's not null then seems like assigning wrong references
use the vs debugger and step through to see what the reference is and if it's being populated
also execution ordering if this is all being done in a single frame perhaps
so this should in theory work?
I already changed it to just use CharacterLogic.Character instead of assiging CharacterVisuals.Character
Separation from visuals and logic, they should work no matter what order you load them, but Visuals needs some Character to bind to, but it can hang out in the scene until it is.
Character logic does not need to know about visuals, but visuals do need a reference to character. Character should work completely without visuals.
In theory
Only problem with this is you need to handle the execution if it's chopped apart like this, so keeping the visuals as a field to the character logic would guarantee it load correctly (this would go against the idea that the character logic does not need to know about the visuals but who cares)
Otherwise you do like a manager like RequestUI
Hello, I don't know much about angles so I needed to ask, if you want your bullets to travel higher or lower depending on the x-value of the player's rotation (such as if the x value of the player's rotation > 20 then travel until transform.position.y == 20f or something) can you just do rotX = playerTransform.rotation.x or do you need to convert it to something before doing the conditional statements?
probably give some more context of the projectile behaviour
if you rotate your character's x, it will affect the tilt, so a negative x rotation would make them face upwards
in the traditional xyz rotation (y world up)
hi there! good morning
Using chatgpt trying to get working the same effect for portals but cannot get working this. Just read this https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@7.2/manual/rendering-to-a-render-texture.html and https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@7.2/manual/universal-additional-camera-data.html
start by reading the error
feel like a chatgpt error because UniversalAdditionalCameraData' does not contain a definition for 'cameraOutput'
but documentation tell me myUniversalAdditionalCameraData.cameraOutput = CameraOutput.Texture;
myCamera.targetTexture = myRenderTexture;
Looks like you're trying to put a Texture into a cameraOutput, obviously that won't work
also what version of URP are you using? because those docs are for a really old version. and of course GPT is just guessing what you should be doing based on predicting what text is most likely next after the text it has already generated. it does not know how to do things, especially when things change with newer versions
im trying to adapt brackeys tutorial from portals to urp https://www.youtube.com/watch?v=cuQao3hEKfs
Get all Udemy courses for only $10.99: http://bit.ly/BRACKEYSJAN
The link above is an exclusive limited $10 site wide deal that expires soon so... go nuts!
In this video we create a smooth portal effect in Unity!
● Download Shader: https://goo.gl/iKCk1r
● Project on GitHub: https://github.com/Brackeys/Portal-In-Unity
The video is based on th...
I'm just explaining your error, think about it
this is probably before urp
so the way to use a rendertexture to a mesh renderer in scene i understand this step, so in urp i hve to modify a bit the code because there is another section in maincamera with the output
Sebastian's video is probably more informative
yes, it says there is not a definition for cameraoutput, but in unity documentation says this, let me see my urp version maybe you are right
sebastian video?
Experimenting with portals, for science.
The project is available here: https://github.com/SebLague/Portals/tree/master
If you'd like to get early access to new projects, or simply want to support me in creating more videos, please visit https://www.patreon.com/SebastianLague
Resources I used:
http://tomhulton.blogspot.com/2015/08/portal-rende...
thanks https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@14.0/manual/rendering-to-a-render-texture.html so i dont need to use outputtexture, only myCamera.targetTexture = myRenderTexture;
correct
bracky's implementation uses mostly quaternions but there's problems* with it
i l check right now thanks for the link!
lague has a better matrix implementation of viewing through
var matrix = transform.localToWorldMatrix * inPortal.transform.worldToLocalMatrix * playerCamera.transform.localToWorldMatrix;
outPortalCam.transform.SetPositionAndRotation(matrix.GetColumn(3), matrix.rotation);
Basically that
Tried adding & removing nullable, tried adding a (Character) cast, I know I'm doing something silly but I don't see it:
Character Character = CloudSave.LoadCharacterData(context, gameApiClient);
your ide should give you the exact type it wants, if you do var character then refactor to use explicit type
bleh just missing async in the function -_-
and await in the call
weird error though
well yea without await you're returning the task
Here's the working version:
I would just expect not being able to call it
but it sorta makes sense
not sure what you mean on that one. But yeah most Cloud functions are async cause of nature of web :p
I would expect it requires await if you're trying to call a Task
but I guess there are use cases where you want to store the actual Task instead?
yeah if you're running a bunch of tasks they can be put in a special class for it
etc
async/await is just syntactic sugar for calling and handling Tasks manually
hello, i am making a top down game in unity 2d, and i want the camera and movement behaviour a lil different.
- I want the camera angle to follow the mouse
- The movement i have currently is w for going straight up but i want it to be facing the cursor.
new to unity, i wonder how can i do that
Literally hundreds of tutorials and videos online for a character controller/camera.
What are you struggling with?
hello. how rotate the 3d object to other 3d object?
after upgrade this example to urp the portal become grey, feel like the shader isnt working with ur.... hmmm
nevermind i just found the solution inside one comment 😛
it's just a screen space position shader
it's also a single node if you want to do it via shader graph
https://cdn.discordapp.com/attachments/448923113921576992/1179903410707910676/Unity_Hq4q5nJPX9.webm
it's what devs use to create those neat galaxy effects
both things dont work together, if camera works then movement becomes bad.
https://www.youtube.com/shorts/3J7vD8c0QsY
this type of camera and movement i want but cant find any video about it
firefly triple kill from distance ✅✅✅
https://www.youtube.com/watch?v=Geb_PnF1wOk
googled it for ya
If you need help, come chat on Discord: https://discord.gg/Cyrcnmf
Site: https://indienuggets.com/
Learn how to make an object always look in the direction of the mouse
Icons made by https://www.flaticon.com/authors/smashicon
Hi, I have a problem, I save chest states and delete them with the m key, it happens that when I save or delete them, only the saved and deleted ones are applied to the scene I am in, how can I apply them to all the scenes the changes? I've been trying for a long time, please help
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
im try rotation the 3d object, but its need +90 degree. how add this?
Vector3 direction = target.transform.position - transform.position;
Quaternion rotation = Quaternion.LookRotation(direction, new Vector3(0, 0, 1));
transform.rotation = rotation;
small question how can i rotate the camera if i have a angle value
in that video it shows you using Atan2 as well
Hi guys can anyone help me with this, its simple, but i rly idk how to do it, i created a slide bar on a canvas, and then i applied an effect for my camera, but the effect affects the canvas as well, and my slider bar becomes distorted, how can i put a straight bar again?
this is a code channel
Mornin' all,
Soooooo, I'm following a tutorial on infinite scrolling background using tiles, the tutorial is a 2D solution and I'm trying to 'convert' it to 3D.
I'm not overly experienced with Overlap Circle/OverlapSphere/SphereCast etc. so I'm not 100% sure how to get this to work.
Would anyone be okay to take a look at the code and point me in the right direction please? (I've left the original OverlapCircle code in but commented out to compare)
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
So I'm following a first person tutorial by this guy
and I can't get it to work
the capsule just falls
Do you have a collider anywhere?
yeah
which channel you recommend ?
What is the player position before you click play? And the ground Position (specifically the Y position)
Show the scene view when not in Play mode
and for the ground:
Focused on the player.
Okay, first guess is that your collider is below the ground, so it's not detecting the collision. Try raising up the player GameObject to about 0.5
That doesn't tell me anything dude 😕
Does the ground have a collider
it just pushes the player up now
why do you have a rigidbody on the ground?
I didn't add it?
it didn't add itself
removed it
As you're following a tutorial, go back and retrace every step slowly. I know that guys tutorials, and he's pretty good.
Just a cheeky bump 🫣
I think you want CheckSphere
Hi, I have a problem, I save chest states and delete them with the m key, it happens that when I save or delete them, only the saved and deleted ones are applied to the scene I am in, how can I apply them to all the scenes the changes? I've been trying for a long time, please help
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I thought the same, but was a bit confused by it as CheckSphere doesn't return a boolean (like OverlapCircle does), so not really sure how to use it in this context.
Ignore my last reply, was being a spanner and got confused with all the different sphere stuff. lol.
Lmao was gonna say
Easily done lol
okay, I understand how to do this with music for example, but I don't understand how when loading data, apply it to all scenes even if I don't change scenes
I’ll be honest I’ve not used it yet so I’m not sure how best to implement it but that should be what you want
Maybe someone else will be around that’s actually used it
Why does the movement make the sprite so stuttery?
private void Move()
{
if (!_canMove) return;
var rigidBodyVelocity = _rigidbody2D.velocity;
var movementVelocity = new Vector2(_moveInput.x * _movementSpeed, rigidBodyVelocity.y);
_rigidbody2D.velocity = movementVelocity;
}
Not 100% sure why but one thing to do is add a little drag
That looks like camera stutter more than movement stutter. Can't tell for sure because there are no reference points in the background
first thing, when is this called?
In something I’m making someone thought there was a bug where the player went flying, turns out it was just the camera
boys I figured out how to move the camera 🔥🔥🔥🔥🔥
Hmmm. Okay, so CheckSphere seems to be the way to go, but it's introduced a new issue that I'm not sure how to fix. 😕
I could obviously put a collision check on the tiles, but that would introduce a lot more processing.
Any ideas? 😕
Why… why is your script in scripts/ignore lmao
that's the script for holding the camera
Had a quick look at overlapsphere
Could use that and instead of if(overlap do if(overlap.count > 0
Okay cool. Will give that a go 🙂
https://forum.unity.com/threads/cinemachine-crazy-jitter.465865/
Managed to find out the reason for the stuttering in case anyone is interested (or this is asked again)
One must enable interpolation on the rigidbody
Makes sense
Dangit. lol.
Same result as the CheckSphere route. Annoying because I know exactly why it's doing it, I'm just not sure how to fix it. lol.
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
You probably want a layermask
Collider[] hitColliders = Physics.OverlapSphere(player.transform.position, checkerRadius);
if (hitColliders.Length > 0)
{
Debug.Log("Hit Triggered");
noTerrainPosition = player.transform.position + new Vector3(xPosition, yPosition, zPosition);
SpawnChunk();
}
This is what I've got. Even with a layerMask it does the same thing. It's happening basically because I'm calling the check every frame, so it's detecting the current collider every frame. I'm just not really sure what the difference in the detection side is between the circle and sphere methods is 😕
Can you show the 2D code again rq?
if (Physics2D.OverlapCircle(player.transform.position + new Vector3(xPosition, yPosition, zPosition), checkerRadius, terrainMask))
{
Debug.Log("Hit Triggered");
noTerrainPosition = player.transform.position + new Vector3(xPosition, yPosition, zPosition);
SpawnChunk();
}
Oh wait, 1 sec, I did miss something.
Physics2D wont work in 3d physics, two different systems
Yeah it’s just to compare the logic
Theyre converting from a 2D tutorial to 3D
Yes I know this, I'm not trying to use 2d with 3d.
Gah, this is really frustrating. lol.
Oh, I think I may have figured it.
Needed to change the colliders check to <=0 instead of >0
Maybe not, but it's doing the same thing as the 2D tutorial is doing, so I can move onto the next stage and see what happens. lol.
Nothing. I figured it wouldn't because the collider count won't go above 1 until a new tile is spawned, which will never happen because a new tile will never spawn (if I understand the logic correctly)
I think something is a little broken then but I guess you’ll find out in future, hard to tell without an editor in front of me to play with lol
perhaps this is the problem?
Yeah I know what you mean. I get the same thing.
boys how do i add 2 tags?
The vector3 offset is basically to 'move' the sphere to that point based on the players movement, so when the check moves off the 'current' tile, the next one spawns (If that makes any sense.)
use .CompareTag instead, and you cant, you have to write it twice the whole compare by using a && operator
but a gameobject can have only one tag
exactly, so probably want a || instead of &&
If you want to receive help in this channel you're going to have to specify what that would be
collision doesn't work
That's not related to this channel
But considering we started this conversation now, read this https://unity.huh.how/physics-messages/3d-physics-messages
ight thanks
And also this to see if your methods are called by logging a message https://unity.huh.how/debugging/logging/how-to
//portrait resolution : 3/4 only
//landscape resolution : 16/9 only
if((r.width/r.height) == (3 / 4))
{
portraitResolutions[dropDown.options.Count] = r;
if (!GameManager.Instance.isLandscape)
{
newOptionData = new OptionData(GetResolutionText(r));
}
}
else if ((r.width / r.height) == (16 / 9))
{
landscapeResolutions[dropDown.options.Count] = r;
if (GameManager.Instance.isLandscape)
{
newOptionData = new OptionData(GetResolutionText(r));
}
}```
do u guys think this code can be further optimized?
what this script does is basically obtain all resolution possible, and group them into 2 kinds of resolutions, add them to a list for later display
have you actually tested this?
