#💻┃code-beginner
1 messages · Page 731 of 1
as long as it shows the setup / issue clearly sure
i mean the code i did with the help of chatgpt and still that doesnt fix anything
I wouldn't trust chatgpt with anything but writing stories tbh.
chatgpt isnt some magical tool that will code / fix things for you.. Its doing basic assumptions based on patterns that already exists, it cannot think or does it deduce anything useful most of th etime
more like Fido
i am trying to learn through him and unity learn site and youtube
It will point you in the wrong direction though and make bad guesses.
believe me, if it was a good learning tool we would be recommending it left and right.. Its not a good tool for that
there is a reason it carries a big stigma
i can see it does alot of mistakes tbh but i try to understand and i get it mistakes now but the things which are new probably i cant understand
which is the issue - it will make mistakes, and you won't be able to catch them
just use reputable sources instead
if you're new you cannot recognize the mistakes, thats the core of the problem
its a cyclic problem
its what i am trying to do i hope this will give you the idea of screen
half my convos with gpt
me: "cannot do x because xyz"
gpt: "Oh yes you're right my mistake.." *proceeds to make a even more sloppy response *
accurate xD
it may not seem like it but this is already a complicated setup, so what happening instead of what you expect?
If you're posting !code, use the provided links . . .
is this generated? half this doesnt seem to make sense?
I think the new bot doesn't like parsing commands within a message 😢
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
where do we submit features for this bot?
lol its basic bitch af.. would be nice if we can make it reply a specific person instead of the invoker of command
something like !code [user] and send bot reply to them but i guess can be easily abused for spam...double edge sword of development...
yes
yeahh exactly, aint no one wants to fix that.. burn it with Fire 🔥
start fresh with code you wrote and actually understand, i think there are youtubers like SamYam that cover Input touch system
i learned most of my coding first from chatgpt then when it works i learn it also watch some toturials at youtube
i appreciate that bro
guess i am gonna learn alot here
yes lol
welcome to development
learning new things should be 70% of your daily routines
I agree. Samyam has great input tutorials . . .
i learn quite a bit of newinputsysten but i couldnt really find something in youtube covering the area of touchscreen with 50% screen giving to look they make a joystick too for lookrotation
gotta give a look to samyam
exactly bro this code is kinda weird i myself dont like this
is anyone able to help me diagnose why i'm getting a jitter when looking around & moving with my character controller?
i've tried to use a preset asset for a character controller as i don't want to code my own for this small project
yea maybe. If you posted the info, it would probably get you more help
" a preset asset for a character controller" needs to be more specific
common issues are usually mismatching between Update loop, Fixed Loop and Camera Loop
You'll probably need to provide more context
yeah fair enough, didn't want to type a massive thing into the channel and get ignored lol - happnened too many times before
i'm using a preset asset i found in this video - https://www.youtube.com/watch?v=I3CXMP_PoaM
i've made sure that i'm rotating the rigidbody and player separately to the camera
Modular Physics-Based Character Controller
Take your Unity projects to the next level with this fully modular physics-based character controller! Designed for flexibility and realism, this asset offers a dynamic and customizable movement system that integrates seamlessly into any game—whether it's a platformer, action game, or simulation.
Key...
should i use rigidbody or charactercontroller for player controls?
I can provide code, screenshots of what's wrong, etc.
this is the code inside the CharacterLook script
private void Update()
{
Vector3 look = Vector3.Scale(inputProvider.Look, sensitivity);
rotation += look * Time.deltaTime;
rotation.x = Mathf.Clamp(rotation.x, -89.9f, 89.9f);
cameraRoot.localRotation = Quaternion.AngleAxis(rotation.x, Vector3.right);
transform.localRotation = Quaternion.AngleAxis(rotation.y, Vector3.up);
Usually camera jittering is resolved by using interpolation mode with moving objects
depends on what you want for your game
there is no right anwser here
each has pros and cons
i've got my rigidbody set to interpolate but not fixed. and i'm getting jitter with objects that aren't even moving lol, just anything
if my game is more focused on player controls maybe like cod or cs2
what are some approaches for a weapon system with a lot of weapons with animations
Scriptable Objects
i am kinda familiar with rigidbody settings tough
rigidbody if a big part of your game is physics based - if you want your character to react to the physics engine, whereas if you don't need realistic physics reactions then you can do character controller
how'd i store animations and models in that?
its not just "the settings" but how they behave, interact etc.
the same way you store any other asset
& access withvar myAnimation = mySo.GunAnimation
ScriptableObjects are similar to regular classes (well they are technically), they should just not reference scene components.. the rest is fair game
is there an animation class?
sure for Animation clip type
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/AnimationClip.html
though you typically can grab an entire controller as well
Rigid body physics will be using the Rigid body physics system (more applicable for actual physics where you're rolling a ball or something). Character Controller is a tool for providing basic locomotion and basic collision detection/responses (you'll need to implement some stuff yourself). Rigid body in kinematic mode would give you full physics detection without simulating anything (if you're just needing detection and implementing your own game physics).
-# god i hate 3D animation
thanks :)
Not sure. Normally you'd just have physics applied in the Fixed Update, Input detected in update and camera movement in late update (if it's moving). I'm assuming your camera is moving.
camera is a child of cameraroot which is being rotated. it's first person controller so yes camera is moving.
i'll try changing the cameraroot rotation to lateupdate
use Cinemachine and half the worries about camera and update loops is slashed in half..
Cinemachine == "life";
best investment unity made, that and textmesh pro.. life changers
thats when unity was still making good decisions at the corporate / management levels
I second the use of SOs, especially if you want individual stats for each weapon instance . . .
okay just looked into cinemachine and turns out the character controller i'm using actually uses cinemachine but didn't mention that part. however, on the prefab i'm seeing this
this isn't a code question, but it's likely that the asset you are using was designed with cinemachine 2 but your project might have cinemachine 3 installed and there are some breaking changes. if that is the case then you'd need to go through and change the relevant stuff https://docs.unity3d.com/Packages/com.unity.cinemachine@3.1/manual/CinemachineUpgradeFrom2.html
Cinemachine 2.x implemented the CM pipeline on a hidden GameObject child of the vcam, named "cm". This has been removed in CM 3.0, and CM pipeline components (such as OrbitalFollow or RotationComposer) are now implemented directly as components on the CinemachineCamera GameObject. You can access them as you would any other components: GetCinemcachineComponent() is no longer necessary, just use GetComponent().
what is best way to move character in 3d enviornment
there is no "best", it entirely depends on your needs. there are plenty of tutorials for character movement and even plenty of premade assets that do most of the work for you so just find something that suits your needs
i would appreciate if you can provide me with some links to website to yt videos to understand
okayyy
hey so I have a parent object
and it has a child with a collider on it
I grabbed the collider with GetComponentinChildren<>()
Now can I call smth like OnTriggerEnter2D with that collider?
Are you trying to check if that collider is currently overlapping something else?
Anyways to figure out what the engle between a vector3 and an objects forward direction?
I'm checking if the collider hit the enemy
I have a melee weapon with a pivot, the weapon scales from the pivot so it kind of extends forward and it has its own collider, if the weapon hits an enemy I want that trigger to register in the code in the pivot
if that doesn't make sense I'll just make it in the weapon itself
Why can't you just use OnTriggerEnter
I did, but it's not regestering (I'm using it in the pivott not the weapon itself)
If the weapon has the collider you want to check and the pivot has the code you want to run then have the weapon call a function on the pivot when it registers the hit
I just started, how do I open a code file lol
!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
• :question: Other/None
i recommend visual studio
You don't manually call OnTriggerEnter, the Unity engine does . . .
/// Returns steering input in [-1,1] to turn the vehicle toward targetWorld.
/// - fullLockAtAngleDeg: angular error (deg) that maps to |input| = 1
/// (usually your car's max steer angle).
/// - deadzoneDeg: ignore tiny angle jitter.
/// - useVehicleUp: use vehicle.up for banked roads; otherwise world up.
float SteerToward(Vector3 targetWorld,
float fullLockAtAngleDeg = 45f,
float deadzoneDeg = 0.1f,
bool useVehicleUp = true)
{
Vector3 up = useVehicleUp ? transform.up : Vector3.up;
// Project onto ground plane so slopes don't skew the angle.
Vector3 fwd = Vector3.ProjectOnPlane(transform.forward, up).normalized;
Vector3 toT = Vector3.ProjectOnPlane(targetWorld - transform.position, up);
if (toT.sqrMagnitude < 1e-6f || fwd.sqrMagnitude < 1e-6f) return 0f;
float angDeg = Vector3.SignedAngle(fwd, toT.normalized, up); // + left, - right
if (Mathf.Abs(angDeg) <= deadzoneDeg) return 0f;
// Map angle to input. Negate to match your convention: left -> negative.
float input = -angDeg / Mathf.Max(1e-3f, fullLockAtAngleDeg);
return Mathf.Clamp(input, -1f, 1f);
}
anyone see a problem with my logic? the steering just goes back and fourth between -1 and 1 its not really working as intended.
Hey there, does anyone know why a part of this script is grayed out?
because you're not calling SpawnEnemy(); anywhere see how it says 0 references?
its basically visual studios way to tell you its safe to be deleted
but that doesn't really apply for unity
Ah that makes sense, I getcha
because if you're calling it in start or awake it might still be grayed out
hey im just learning stateMachines and got my state machine working mostly. i got an attack state which i dont know how to implement. because attacking should be possible while walking so how would i transition to the state?
am i supposed to make a second state machine for cases like attacking or using spells etc?
this should be handled correctly if your ide is configured properly. known messages won't be marked unused.
I need help, anybody got a video on soulslike movement?
do you have any examples of that? afaik that just should not happen at all, given that the grayed out method marks it being unused, and calling it in another method would make it well, used
youtube does
idk ide is configured fine but awake and update etc still grayed out.
i can't find any 😭
they are all videos on how they make it
not on how i can make it
what ide are you using?
is that not the same thing
visual studio 2022
that should handle unity messages just fine. are they not showing up in blue?
No, if they show how they make it they don't show the code and how they do some stuff, if they show how i can make it they go into detail and show everything they do
maybe look for dev logs, those sometimes dont show code and just explain what they did
hmm, 😭
wait do you mean you want to see the code? i'm a bit confused
i want a video on how they do it and they show them coding and explaining it.
Yes, I would create a separate state machine for attacking . . .
okay thank you
anybody maybe just got tips on soulslike movement?
like what should i definitly add
and what can i choose
there are videos for exactly that though, like this one https://www.youtube.com/watch?v=jR0LNvesnOE
Watch the entire course at http://sharpaccent.com
Jump start your next game! https://goo.gl/cDntqy
For freelance inquiries unityguru23@gmail.com
http://sharpaccent.com
FOLLOW ME ON SOCIALS:
Discord - https://discordapp.com/invite/8DKteeZ
Twitter - https://twitter.com/AccentTutorials
Instagram - https://www.instagram.com/sharp_accent/
Support th...
thx
part 151 lord.
It's just regular movement. You control the speed (move/turn) through variables. That'll give you a certain feel or style of play . . .
it's not completely regular tho, you got the dashing, and other stuff
I really wish these things would stop calling themselves tutorials and just call themselves "devlogs" which they are
Yes, like almost every other game. The feel (speed) of the movement is what makes the games different . . .
true
it's probably so that people looking for tutorials to copy code from will also find this video, I guess
With separate state machines, you can overlap to allow attacking while running or jumping . . .
Yes and then we have to deal with the fallout from that
hey guys I have a question
I have a weapon that's supposed to be always invisble (sheathed) until I press some input to do the attack sequence and actually show the weapn and stuff, how can I do that?
I want to disable the spriteRenderer and collider components as a way to do that, are there other options? would it be better to disable the object and awaken it from another object?
Lookup Unity tutorials on Animator states
I'm not using an animator
I've got to go but for better support maybe you should provide further context otherwise it's pretty open ended.
if disabling the sprite renderer and collider works, then that's fine. disabling the gameobject does pretty much the same thing
private IEnumerator PhaseThreeAttack(Vector3 minimumScale, Vector3 maximumScale,float scaleRate)
{
hasAttacked = true;
float originalScaleRate = scaleRate;
Vector3 originalScale = transform.localScale;
Vector3 newScale = originalScale;
while(newScale.x < maximumScale.x)
{
newScale = Vector3.Lerp(minimumScale, maximumScale, scaleRate);
scaleRate += Time.deltaTime;
transform.localScale = newScale;
yield return null;
}
yield return new WaitForSeconds(0.1f);
scaleRate = originalScaleRate;
while (newScale.x > minimumScale.x)
{
newScale = Vector3.Lerp(maximumScale, minimumScale, scaleRate);
scaleRate +=Time.deltaTime;
transform.localScale = newScale;
yield return null;
}
yield return new WaitForSeconds(0.3f);
this.gameObject.SetActive(false);
hasAttacked = false;
}```
this is basically the attack code
```C#
if (Input.GetMouseButtonDown(1))
{
if(!hasAttacked)
{
Vector3 objectScale = transform.localScale;
Vector3 targetScale = new Vector3(1.6f, 0.5f, 1);
float scaleRate = 0.8f;
StartCoroutine(PhaseThreeAttack(objectScale,targetScale, scaleRate));
}```
this is it's call
I want to disable and enable the object on right mouse click like so but disabling the object makes this script disabled too thus it is not awakened again.
disabling the gameObject also disables the script so I can't really reenable it
then just disable the sprite renderer and collider and whatever other components it has that should be disabled
so I will just attack the script to another gameObject that won't get disabled I guess, though I will try disabling the rendeder and collider first.
is there a equivalent to Resources.LoadAll<Sprite> but without requiring to create a resource folder?
addressables most likely
i tried it and it created another addresable folder
#if UNITY_EDITOR
[Button]
public void FetchSprites()
{
// Sprites = Resources.LoadAll<Sprite>("Skewer");
}
#endif
this is what i try to do
should prob just explain usecase
i want the sprite thingys remain in its graphic sprites folder
Doesnt addressable let you do that you just link it to a Group ?
without needing dedicated folder
you technically can use File.IO too but idk just seems dirty
no idea, havent use it before but when i tick the addressable box in the inspector, it said need to be move to addressable folder
usually i just shift hold multiple objects and drag to inspector but this package completely change the inspector list and doesnt allow drag multiple anymore
what do you mean..
i recalled you can fine..
Enable the Addressable checkbox in the Inspector window for either the asset itself or for its parent folder.
only if it lived in Resources
If you make an asset in a Resources folder Addressable, Unity moves the asset out of the Resources folder. You can move the asset to a different folder in your Project, but you cannot store Addressable assets in a Resources folder.
https://docs.unity3d.com/Packages/com.unity.addressables@2.7/manual/get-started-make-addressable.html
but this seems overkil , you should be able to just drag and drop them if its not a special usecase
yes why can't you just do that for sprites?
his package completely change the inspector list and doesnt allow drag multiple anymore
even odin
whos package ? what?
currently tri inspector, but im looking at a odin inspector project also
cant drag them anymore
if it doesn't support multi-selected item drop in...that would be pretty trash..
dang i heard odin is very standard
ehh depends on the uses
but i will look into addresabble
thats still probably not a good usecase here.. you should probably get a good working inspector
are whatever attributes they have even worth breaking the workflow?
should probably get a good working inspector
wym
mean i should rip these package out ?
I dont understand whats wrong with just using the regular inspector? is there something specific you want
half the time I'm not even looking at the inspector lol
considering it, this package allow me to easier use serializeReference and modify the list view less cluster, i dont have very deep knowledge into drawer
idk is having that worth breaking the array drag n drop feature?
Maybe something you need to enable or something? I find it puzzling that a Unity asset would break such a needed feature
using inspector is the way to go anyway, using Resources / Addressables is overkill here esp to skirt around an asset breaking something
i only need to fetch once in editor so should be fine
where should i learn how to script (i wanna do mostly vr and gorilla tag fan gtame game type of games)
doesn't matter what genre' ur scripting or what "input" you use.. coding is coding..
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
ok i feel like im missing something obvious.
so i have a game object that on it's root is made to look at the camera via transform.lookat.
meanwhile im trying to rotate the sprite renderer within it by the z axis.
however when i set it in script, my results gets weird, sometimes giving me the mirrored direction of where i wanted it pointed towards.
how do i sort this out, cause i feel like im missing something obvious
on the root is simply a script that runs the look at to point at the camera.
cs transform.LookAt(cam.transform.position);
in the sprite child, even though i wanted to only rotate the z axis to allow the root to handle the rest, it doesn't go that way.
the closest i got was this. this aims in the correct direction for me, but for some reason it ignores the rotation on it's parent script. and just goes flat when i rotate around it.
cs transform.rotation = Quaternion.Euler(0,0,angle)
so... yeah
how do i program physics simulated clay
Sure, you can freely change the sprite on the SpriteRenderer component in code.
figured it out, iw as definitely overlooking. i wanted tranform local rotation with eulers. (also the sprite was using needed a rotation offset to make it look like it's going in the right direction)
Feel like I am going crazy, why is the game saying the playerTarget Transform is itself (En_SculptedDemon) instead of the correct game object assigned in the GUI (Player)
using UnityEngine;
public class EnemyChase : MonoBehaviour
{
public Transform playerTarget;
private CharacterController enemyController;
public float moveSpeed = 20f;
private Vector3 direction;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
playerTarget = GetComponent<Transform>();
enemyController = GetComponent<CharacterController>();
}
// Update is called once per frame
void FixedUpdate()
{
MoveEnemyTowardsPlayer();
}
private void MoveEnemyTowardsPlayer()
{
direction = (playerTarget.position - transform.position).normalized;
Debug.Log("playerTarget.position" + playerTarget.position + playerTarget.name);
enemyController.Move(direction * moveSpeed * Time.deltaTime);
Debug.Log("transform.position" + transform.position);
}
}
So instead of modifying a variable from another script, it's better to call a function, right? Is there a time when it's "good practice" to modify a public variable from another script?
really just when you need to. but typically you would use properties rather than public fields. properties also get rid of the need for manual get/set methods that some other languages recommend
So just do it if you need to but "try not to if you can help it" I guess.
https://pastebin.com/yAaybB58
Any reason as to why my enemies stop spawning after like 5 spawn? something around that. I made sure to check if game state is being set to over but its not its always playing.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Yeah, you can manually call and play an animation state by name.
lists are the version of arrays that can be expanded during runtime right?
Lists are closely related to arrays, collecting multiple values of the same type in a single variable. They are much easier to deal with when it comes to adding, removing, and updating elements, but their elements aren’t stored sequentially. This can sometimes lead to a higher performance cost over arrays.
yessir
Does anyone have any tips on reducing lag that OpenCV does when reading hand inputs. I did a project where I could read hand inputs outside of Unity with python and I don't remember that lagging at all. But with Unity using OpenCV whenever the camera comes on sometimes there's lag spikes.
I'm wondering if there's any tips or code I can remove to help reduce it
In your code, you assign playerTarget using GetComponent, which checks for the component on this GameObject (the one the script is attached to). Basically, you assign it to itself, which overrides what was originally assigned via the inspector . . .
^ chatgpt likes to do that alot.. (it'll give u a public or serialized field to assign in the inspector) but it'll also add a GetComponent in the Start() or Awake() for whatever reason it decides to do that
No, accessing an internal field from another script is never good practice. It's called encapsulation. Use a property or a method to change the field
This helps if you need to check/set limits, send an event, etc. Directly assigning its value from an outside script bypasses that
When you use dot notation, the members that appear indicate what you're allowed to control, hiding unnecessary or internal data that the class is responsible for maintaining . . .
Really? That's sabotage. GPT on another level . . .
A list is one of many collections that can expand. It does not have a set size . . .
So if I want to for example -1 HP from an enemy from another script just add TookDamage() in the script and call that from the other script? That's the right way? Maybe not the best example but just as an example.
Yeah, this is normal. You'd check if the collided object is an enemy or IDamageable (when using an interface). Then access the component/interface to call ApplyDamage(value) . . .
gotcha, thanks 🙂
Hey everyone, has anyone seen a good guide / course on how to use Unity Debugger / Profiler tools? Would appreciate any recommendations!
In this video, we look at an overview of the Unity Profiler in Unity 2022 LTS.
You’ll learn more about profiling your game to identify bottlenecks, the Profiler’s interface, and how to identify issues that need fixing.
The Unity Profiler is a tool for creators who want to understand performance issues and how to address them.
Helpful re...
can't say whats the best as i kinda learned debugging along the way.. but can't beat starting at Unity itself
Thanks, I'll take a look a their documentation!
😂 🤣
"Redundancy" it says
Has Unity stated what version of C# they're potentially upgrading to once they get around to upgrading the scripting system to .NET Core?
it is supposed to be whatever is the latest release at the time
I see, thanks
how do i program physics simulated clay
Define what it means first, break it down into smaller steps/logic and implement it.
anyone know whats happend now?
its was working fine before 20sec
and cleancode doesnt solve it
there are two namespaces withButton class. It doesn't know which to use
you mean about public button?
yes thats why I said Button
also i didnt find button field in unity
and how should i make 2 buttons?
what does that have to do with the error ?
also what about image error?
just there is 1 image
did you not also lookup the error you have ? it explains whats wrong..
https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0104
the quantity of the fields have nothing to do with the error
no but i mean the button error becouse i have 2 button so what about image?
just have1
okay so you read nothing and just making shit up?
for c# no
since 1 years
before yes
some errors which i get at this time
nowhere did I mention c#. I'm talking about the link I just sent
its for c# so
great..so .. did you not click it and maybe informing yourself about the error instead of making it up why it error
c# is chsarp
the error has nothing to do with how many Button references you have...
UnityEngine.UI & UnityEngine.UIElements namespaces both Have Image and Button. The compiler has no idea which ones you are trying to reference from
couse it was working i didnt change anything and when thats happend to me normally be compilor or ide issue so
thats why im asking
oh
however it got there, its there.. hence the error
I specifically said namespaces multiple times and the link of error sent mentions them, nowhere is variables mentioned
couse i dont know what "namespace" mean here so i asked about public button and you said yes
Anyway there's no errors now should i find button Field now?
when you're not sure what something is look it up & ask for clarification.. anyway if you fixed the compile error just drop in the reference to component through the inspector
where ? 🙂
unsaved changes, compile errors, wrong namespaces was used for them.
check all of them
nothing but i will try attach again
same
same what? I told you where to check
prove all 3
no errors and attach &save and namespace i will send code now
using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using UnityEditor.UI;
using UnityEngine;
using UnityEngine.UIElements;
public class player : MonoBehaviour
{
public Rigidbody2D rb;
public Image leftbtn;
Vector2 xdirection;
public Button leftb;
public Button rightb;
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Button"))
{
Debug.Log("left");
transform.Translate(Vector2.left * 0.5f);
}
/*
xdirection = new Vector2(Input.GetAxisRaw("Horizontal"), 0);
rb.velocity = xdirection * 600 * Time.deltaTime;
*/
}
}
wrong namespace
also when someone asks to prove something you normally provide visuals, taking your word isn't proof for someone else.
why do you have UnityEditor.UI included
i think its automatically imports
you gotta pay attention to those things
some namespaces like that one left unchecked from UnityEditor would prevent you to build any executables..
i let copilor do that for safe time 🙂
it's now costing you time because it's writing bullshit and you don't know how to fix it
so should i replace it with which one just unityeditor ui?
genAI are power tools. if you don't know how to use them properly you'll end up injuring yourself
no its will be fine when i differentiating bettwen them
there are 3 that don't belong
you're a beginner. you do not have the experience necessary, period.
which?
just stay away from genAI until you get the experience. it'll be hurting more than helping.
🙂
two are grayed out in the IDE. the third is the UI Toolkit one that had Image/Button in it
i mean which should i delet?
the ones that are grayed out and the extra one that nav mentioned
its mean its not used so why its should make this issue?
for both that are unused - you'll end up with suggestions from these namespaces, which will be noise for the actual types you want.
for the UnityEditor one - just including it without conditionals will make it fail builds.
for the UIElements one - you are using the wrong namespace so you're getting the wrong type.
there is no errors just there is no button fields also so will it fix if i changed ui import?
i will try something :/
!collab
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**
what did you mean
job posts are not accepted here, please remove your post
see the bot message
Ok its works with change it to just ui but how i can make if this button down is specific variable?
nocodes in it for that
the onclick event is accessible through code
not everything is going to be spoonfed to you
for movement i need it up and down so
so go research how to do that then
6 hours of searching for now i think 🙂
I'm making a camera drag functionality, like if you were dragging a map
and i went crazy to figure out why it was not moving 1:1
it turns out this was happening because of "Scale"
and it looks like this part of unity editor has no api?
So my questions are: is this how game window is scaled in engine too (like if you shrink/expand the window) or is this purely editor future? should i be worried about Unity Input system Drag [Delta] breaking if the window size changes in compiled game?
This is purely an editor feature
And nothing
Just do script for every button with pointer
And i need to make it in same player script so
Hi it is hard for me to explain this :) but it try
So what i need is an tutorial or someyone that could help me i want an item pickup code / system so when i am near to an object that i can press E or what ever and it gets picked up and i can drag it around any good tutorials because i dont finde an single one that works :(
pls ping me
i found maany
you are probably not using the right search terms
yes but none of them works
show code
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
A tool for sharing your source code with the world!
i am afk for 15min just ping me :)
oh boi seems like you found that code somewhere and want us to clean it up for you.
nope
so i watched this tutorial
In this video I show how to pick up, rotate, and throw objects in Unity.
CODE (YES YOU HAVE PERMISSION TO USE IT):
https://github.com/JonDevTutorial/PickUpTutorial
and he said you can get the code from the discribion
so yes you want us to fix some random tutorial code 😆
Its clear this beginner code anyway from how its written
i am beginner
or what do you mean by the last sentence
Okay i am looking for an new video
Hey if i learn this video is it possible that i will be able to code in unity?
https://www.youtube.com/watch?v=GhQdlIFylQ8
This course will give you a full introduction into all of the core concepts in C# (aka C Sharp). Follow along with the course and you'll be a C# programmer in no time!
❤️ Support for this channel comes from our friends at Scrimba – the coding platform that's reinvented interactive learning: https://scrimba.com/freecodecamp
⭐️ Content...
This tries to use physics but also moves the object without physics so kinda shit
okay
so do you know schedule1 @grand snow
I want the pysics from the game
because it is made funny
A better way is to use force/change velocity to move the object towards the "hold position"
I dont sorry
video is really old but you will still learn many things
Do you think its enough to start me? I am not trying to make triple a games but just have fun and small projects
@grand snow does this would work?
https://www.youtube.com/watch?v=K06lVKiY-sY&ab_channel=Rytech
In this video I go over the creation of a flexible interaction system in Unity3D.
Join my Discord! ► https://discord.gg/jrRJgfBz2y
How to Make Player Movement ► https://youtu.be/TOPj3uHZgQk
Extra Resources ►
https://docs.unity3d.com/ScriptReference/Physics.Raycast.html
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keyw...
it is ok for now other than that you can check the pinned messages on this channel to learn more c# basics
Thanks!
I check this video briefly and it shows how to move the object with physics which I think is better
https://www.youtube.com/watch?v=6bFCQqabfzo
Lets learn how to pickup and drop objects in Unity. Objects with a Rigidbody component attached can be manipulated like the portal style physics game mechanics. The system can easily be modified to only pick up objects with a certain tag or adjust the speed at which objects are moved. Written in C# and all the content can be found on my Patreon ...
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
Why ping me im not a personal helper
Okay sorry
A tool for sharing your source code with the world!
I am sorry it will not happen again :)
I'm not sure what you want from anyone
What do you mean you can't find the errors? What are they?
(that code doesn't compile btw)
If you're not having errors underlined in red, and lack proper autocomplete you need to configure your IDE
!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
• :question: Other/None
time to learn some c# basics
Ah I see, thanks!
you won´t get far with copy pastin code
Okay i am setting it up :)
Good idea and my errors are wierd
ERRORS:
Assets\PickUpCOntrooller.cs(23,48): error CS1061: 'Transform' does not contain a definition for 'gameobject' and no accessible extension method 'gameobject' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)
Assets\PickUpCOntrooller.cs(21,47): error CS1061: 'Transform' does not contain a definition for 'postion' and no accessible extension method 'postion' accepting a first argument of type 'Transform' could be found (are you missing a using directive or an assembly reference?)
Configure your IDE
Yes but i dont know physics
That is not a C# IDE
!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
• :question: Other/None
Wich is in your oppinion the best one? @north kiln
Rider
Okay got the VS CODE
Why ask if you're just going to ignore the suggestion lol
Because i have never heard of that and i meant from the list xD
Read the list
click on it
oh i have bad wifi so it takes 30 min 
Develop .NET, ASP.NET, .NET Core, Xamarin or Unity applications on Windows, Mac, Linux
it's very good
hi if someone know how can I make specific ui button get down and up in same script please told me because I'm tiered from searching:)
Okay i have it but the script dosent work :((
Wdym get down and up? By scale or position?
Also what are the requirements for that? If it's a click then you could use the button's onClick event to make it go up
whats the script
I am writing it new so give me 5 min
Down like hold up like leave it
Not one click
for input? sounds like you'd want onscreen controls for that
hey guys, anyone got any experience with Cinemachine transitions? I got them to work already but right now it seems to memorize where the camera was before and always transitions back to that state, and I would like it to reset behind the player/vehicle so the transition is always consistant.
Guys this might be an DUMB Question but what did i wrong in this part
**ERROR: **
Invalid expression term ")" Line 21
**CODE: **
if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, pickupRange,))
there's a stray , there
u have a , at the end
ahhh xD
Thanks didnt saw that
now i test it out
Urm okay so in unity i see that i have spelling errors like Tranform instad of Transform but my Editor didnt catch that is there anyway to add that?
!ide yea ur ide shoulda underlined the extra ,
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
• :question: Other/None
Thanks
btw you can just use transform.forward instead of transform.TransformDirection(Vector3.forward)
Sorry again but
I am just using an Tutorial beacuse i need to learn it for my future job and also i like making games xDD
But i will try it out
I dont find the Visual studio thing
you are in the assets tab
it's probably gonna be one of these
Got it i guesss
there are several other steps
yes i have these extensions in Studio
uhhrrmm okay nah i just leave it like this unity is catching so it shouldnt be an problem :)
nope, configure your ide. it is a requirement to get help here
so what should i do now :(
have you installed .net
BOMMBOO CLLLATTT your right i need to bc i miss spelled 13 times 
Looks like it does
you've installed the .net install tool
that doesn't mean you've actually installed .net
no, .net itself isn't a vscode extension
open the command palette and install .net system wide
I am sorry but where it the palette?
Hi there i have this tutorial and this code but it looks like it doesent work any ideas or is the tutorial just not good?
https://www.youtube.com/watch?v=6bFCQqabfzo&ab_channel=SpeedTutor
Lets learn how to pickup and drop objects in Unity. Objects with a Rigidbody component attached can be manipulated like the portal style physics game mechanics. The system can easily be modified to only pick up objects with a certain tag or adjust the speed at which objects are moved. Written in C# and all the content can be found on my Patreon ...
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
A tool for sharing your source code with the world!
am i doing something wrong i mean everyone is gone :(
What error do you get when you press play?
none... but i figured it out :)
How can I copy & paste an object position in Word Scale? Whenever I try it does it in local scale and I can't figure out how to change it
via the inspector
ah true i also have an question but i dont know how to exlpain it so sometimes 0x 0z 0y is like center of map but then other times it is like an diffrent point why?
how can I prevent an object from rotating with its parent?
how do I make it so it doesnt rotate with it
hi i have an problem i want the object to follow the camera complettly so when i go up the item goes up also but it doesent
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
A tool for sharing your source code with the world!
that's because those coordinates aree relative to some object
when its relative to the world (or the map) its shown in the same point
but lets say that you have a sword as a child for the player
then the 0x 0y 0z in that case would be the center of the player, because that's the relative point to it
okay thank you
it shouldnt be a child object if you dont want it to rotate with the parent
so not making it a child object ruins some other stuff
gueses I'll work around that and make it follow the player with a script
If it only needs to follow position not rotation just use a component to set its position to the other objects position
yeah I will do that
btw why does the 2d camera sometimes not show the contents?
it's follolwing the player with a component with a little bit of offset in the x (player.x - 10) but I can't see anything in game
Stop ❌ cross posting keep it in one channel.
how do i stop the coin (small circle) from interacting with the platforms in any way? i tried changing the collision layers so the coin excludes platforms and the platform excludes coins but this still happens
coin's collider
platform's effector
i should be using the collider mask, right? i think it was on by default
i also have this in their rigidbody2d components
Go to project settings -> Physics 2D -> Layer Collision Matrix and disable the coin/platform collision there
the platform effector says it's not using the global layer collision matrix
i'll give it a try though
alright, i had to disable the platform effector's collision mask
my camera is following the player with a -60 offset
for no reason lmao there's no script tht does that
are you using cinemachine? that could be one of the default settings
ive tried and it didnt work and i cant find any resources on the topic
hello guys: i wanted to make the scene of my game a little more "dark" so i downloaded another skybox and messed up with the lightigs, don't really know how does it work so i think i messed up a little bit. at the moment i put againt the default skybox on lighting > environment and set the directional light at its standard parameters, what should i do to reset the lightings setting at its default? at one point i think i misclicked on "generate lightings" but i m not really sure about what have i done.
hi guys why does the object falls when i baked the navmesh?
does Physics.CheckBox() return the collider it interacted with?
@zealous talon holy shit hi
omg
this kind of question is what docs are for 😉
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Physics.CheckBox.html
yeah I read that just wanted to make sure since I needed the collider
I'll create a new collider to interact with then it's supposed to be an AOE kind of thing
you would use OverlapBox/OverlapBoxNonAlloc instead
oh overlap box
i want to put a field of grass instead of the water, any tips of how can i do that?
a terrain w/ grass brush as default ¯_(ツ)_/¯
could it be performative inefficient?
terrains are prettty optimized..
if u were worried about that you could just use the Default Plane and a tileable texture
Do you have a rigid body attached? If so disable gravity on the object, also if it's a static terrain enable the static option near the name on the inspector
quick question :)
can I display that Box to the player ingame? like change the colour of that area?
not directly through the OverlapBox call, you'd have to have something to actually render the box
so I'd have to add a Rendeder to the object attached to the call's script?
i saw on youtube that you can do it adding a terrain, then in edit setting add a grass texture and then painting on the terrain. which grass texture should i take?
check out the asset store they have lots of free materials/textures
Hey guys so i'm trying to use a material and uvs to set a texture but for some reason I think it every mesh:
(every material)
I don't know why this is happening, could someone help me?
what you said doesnt really make sense and wrong channel
goto #1391720450752516147
just looks like a really really dense texture tiling
now I just have more bugs 👍
heck ya.. sounds like a party 🍻
Is there a default Circle texture/sprite in unity?
well, it kinda works now xD
not really.. theres a "knob" but its nasty rasterized with a border
Hey I am trying to create a Sim-style camera system that rotate the camera around the focal point. Currently I have the focal point face the cameras to keep the relative axises the same. However, in some positions, the camera rotation Up/down either inverts or just stops and I do not know how to fix this.
need to Clamp it somehow
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Mathf.Clamp.html
pitch = Mathf.Clamp(pitch, minPitch, maxPitch); something like this may work
I was gonna try to figure that out after it actually moved corretly
Im guessing the rotateAround method isnt the way to go
i'd work that out now and see if the issue still persists afterwards
You'll have to show the code if you want someone to suggest fixes
https://www.youtube.com/watch?v=rnqF6S7PfFA i used this tutorial a while back
not sure its sim enough.. but it helped me out
using System;
using UnityEngine;
using UnityEngine.InputSystem;
public class cameraController : MonoBehaviour
{
public float rotationSpeed = 10.0f;
public GameObject focalPoint;
private InputAction _lookAction;
private InputAction _enableLook;
private float _distance = 10f;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
_lookAction = InputSystem.actions.FindAction("Look");
_enableLook = InputSystem.actions.FindAction("EnableLook");
}
// Update is called once per frame
void Update()
{
if (_enableLook != null && _enableLook.IsPressed())
{
Vector2 lookDelta = _lookAction.ReadValue<Vector2>();
// translate UP/Down
//if ((25 <= transform.rotation.eulerAngles.x || lookDelta.y < 0) && (75 >= transform.rotation.eulerAngles.x || lookDelta.y > 0))
//{
transform.RotateAround(focalPoint.transform.position, Vector3.right, rotationSpeed * Time.deltaTime * lookDelta.y);
//}
// Translate left/right
transform.RotateAround(focalPoint.transform.position, Vector3.up, Time.deltaTime * rotationSpeed * lookDelta.x);
// look at it
transform.LookAt(focalPoint.transform.position);
focalPoint.transform.LookAt(transform.position);
}
}
}
If this is mouse look, don't multiply by deltatime. But that's a separate issue
Vector3.right is in world space, you need to rotate around focalPoint.right
ahhh
focalPoint.transform.right I mean
Actually probably transform.right if the focal point doesn't rotate along with the camera
Hello, Im new to c# and I have a triangle In my scene (2d) that I want to duplicate once it hits a cube named dupicate (already assigned rigitbody and colliders). I was told to use the Instantiate command but all of the tutorials I found were for 3d and for creating objects from ur assets which im not. this script is under the triangle object, if you could link some good tutorials for this itll be great!
It's still Instantiate even if it's 2d and the object is in the scene
oh, well thank you
^ and u use a reference regardless if its a prefab in ur assets or from the scene..
u get a reference to it and stick it in the instantiation method
public GameObject triangleReference;
private void OnCollisionEnter2D(Collision2D collision)
{
GameObject hitObject = collision.gameObject;
// Duplicate the object that hit us
Instantiate(hitObject, hitObject.transform.position, hitObject.transform.rotation);
// Duplicate this GameObject (the one with this script)
Instantiate(gameObject, transform.position, transform.rotation);
// Duplicate the reference at the current position and rotation
Instantiate(triangleReference, transform.position, transform.rotation);
}```
Thank you!
So, I've been given a script to fix as an exercise. I can kinda get it working if I make the list public instead of private, but I don't get why that matters?
is that all of the script?
I don't see how making the List public helps
// Update is called once per frame
void Update()
{
TimeToNextText += Time.deltaTime;
Debug.Log(TimeToNextText);
if (TimeToNextText > 1.5f)
{
TimeToNextText = 0.0f;
CurrentText++;
if (CurrentText >= TextToDisplay.Count)
{
Text.text = TextToDisplay[CurrentText];
CurrentText = 0;
}
}
}
There's the update section too
And thats all of it
hint: the issue is there, not in your previous screenshot
yeah the script has issues, the list being public or private is not one of them
Weird that changing that makes a difference then
it makes the list serialized, which doesn't seem to be the intent of the script unless you have more instructions that say otherwise
ah, nvm, i see the issue now.
yeah ok there is indeed an issue with the first screenshot, and making it public does fix it, but it is most likely not the intended fix.
Oh what issue is that cuz I don't see it
||making the list serialized tells unity to create an instance for the list. it is not initialized otherwise||
Oh lmao I didn't know that
(maybe spoiler that)
it should be fairly obvious by the runtime exception thrown though
I get errors on line 25 and 44, which is TextToDisplay.Add("Congratulation"); and if (CurrentText >= TextToDisplay.Count), which isn't super helpful if the issue is with .Add(), because the course hasn't taught that
did you read what the error said?
What's the error?
NRE
Yes, one of the erros I don't understand.
"NullReferenceException: Object reference not set to an instance of an object"
if you're getting the same error on 2 lines where one has Add and the other doesn't, then it's probably not an issue with the Add 
what is the first word of the exception being thrown
do you understand each of the terms in isolation? if not, which ones don't you understand?
Vaguely. Don't understand Instance.
an instance of a type means some existing object of that type, something you might get from construction
Yeah, it's just jargon to me
...yes, that's what jargon is
I might know what you're saying if I saw it, but the words don't translate
0 is an instance of int, 0.0 is an instance of double
from a monobehaviour, gameObject is an instance of GameObject, transform is an instance of Transform, transform.position is an instance of Vector3
also, does this help at all
Not really, no
try answering that question and it might actually help
If I knew the answer I'd know the answer
you know how to read, right?
Your condescension is very helpful
well all i'm asking right now is for you to literally read the exception and provide the first word. this is not anything technical in any way, it's just reading
"Null"
and do you know what null means
Nothing
and you're saying that does not give any hint as to what the issue might be?
here's a hint: ||it's null||
It gives me a hint that I'm not connecting to an answer, do you get that?
buddy if you don't know (if our leading questions aren't effective) then just say so
we do not need to play this game of sass
in that case you need to start smaller. you are getting way ahead of yourself if you cannot even diagnose a NullReferenceException while being given some assignment to fix a script where that is one of the issues
Okay, we've got to the point of "you're bad at this, just don't do it", so I'll just figure it out myself
also, have you tried googling "nullreferenceexception"
start with beginner c# courses, like the ones pinned in this channel to understand how the language works and what certain things (like being null and being an instance) mean
So lets imagine we write a script that is of type Enemy. So if you created a new enemy from that blueprint, that would be an instance. An instance is a single concrete thing versus the class which is just a blueprint for how the individual instances should be and act.
that should give a lot of info, way more than we can provide here. it's also what you should do if you encounter an issue you don't know about in the future @thorn kiln
oh also this attitude of expecting everyone to spoon feed you the answers and then getting mad when it's suggested you actually learn/research yourself is not going to get you anywhere and is why you are still floundering after being here for as long as you have
Well asking you isn't gonna get me anywhere either then in that case, so why should I care?
you aren't gonna learn ever if you only expect spoonfeeds
figuring stuff out is what learning is
except i genuinely made an effort to help you (without spoonfeeding the answer to you), but you don't understand enough of the basics to even be doing what you are attempting so rather than being pissy, you should consider learning the basics
hell, i even outright stated exactly what the issue is as my first message in this issue
more than i was willing to say, even 😆
Yeah, foolish of me to come to the #💻┃code-beginner channel and expect anything besides people smarter than me to be condescending that I'm not as smart as them
no-one is saying that
we come to this channel with the expectation - the knowledge, even - that the people here will be very unexperienced and know relatively little
what we're asking from you is effort
and also to be less defensive, that would also help
Here's the thing, I get it, you're all so much smarter than me at Unity and C#, but that's clearly given you egos that refuse to let you accept that the way you're trying to explain things isn't working for me, and rather than change, you just get angry at me for not learning the way you're instructing me to
no-one is angry here
hi how do i get the objects behind the stencil shader object to not be rendered? Also how could i get everything outside the stencil layer to not be rendered in the little window?:
Shader "Examples/Stencil"
{
Properties
{
[IntRange] _StencilID ("Stencil ID", Range(0, 255)) = 0
}
SubShader
{
Tags
{
"RenderType" = "Opaque"
"Queue" = "Geometry"
"RenderPipeline" = "UniversalPipeline"
}
Pass
{
Blend Zero One
ZWrite Off
Stencil
{
Ref [_StencilID]
Comp Always
Pass Replace
Fail Keep
}
}
}
}
again - please stop the overly defensive behaviour
i even said before - if our explanations don't work, say so instead of being passive aggressive
nobody is trying to be smarter than you or even angry. you are the one getting angry because we suggested that you take the time to actually put some effort into learning what is wrong.
this is the code channel, perhaps ask in #💻┃unity-talk or #1390346776804069396?
I try, but you guys don't understand that I don't know how to explain what I don't know, and it just makes you get more condescending with each message
there was no condesension here, just further probing questions
This is why the courses and tutorials on Unity Learn are there. To even comprehend the help you are getting you need some basic understanding of the topic.
you did show that you were at least slightly able to explain what you didn't know here, when i prompted
consider that question when you want more info - which part are you having trouble understanding?
If you don't see the condesension, then you're either blind, or you're just too smart to see how different these things come off to someone who doesn't know everything you know
no, there just.. wasn't any. there were some that perhaps could be read as such, but i assure you, no-one was being intentionally condescending
Does any1 know how to limit the speed of a 2d rigitbody object?
I don't know how "you know how to read, right?" isn't condescending
You are struggling with the very basics of the language. And acting out when people trying to explain it to you. If you are unwilling to listen and learn then what are you doing here?
ClampMagnitude the velocity vector
Apparently just sitting in a beginner channel with a bunch of smug people who hang out in here to say "lol, just learn better" to their lessers
this was directly in response to you saying you didn't know the answer to a question that only required you to read what you were seeing on your screen (i even went on to clarify that is what i meant)
If you would've done at lest the Essentials Pathways course you wouldn't be even asking that, because it's one of the first things you would learn.
Yeah, if only
thanks!
do you see the irony of saying that's condescending when you'd just thrown the very passive-aggressive "If I knew the answer I'd know the answer" to a message telling you to pay attention to a certain keyword
You need to actually engage with coursework. It's not there for badges.
Understanding what reference and instance is the first thing you engage with.
Okay, next time I'll send you a screenshot of me egaging with the coursework
I'd rather you would not continue with off-topic here. And maybe go through course work again.
So I've never used AI until a few days ago and I'll have to say. It can actually offer you valid suggestions to improve what you have if you use it right. For example I wasn't sure how to use ! in a line of If code with a lot of conditions and it showed me that I could use extra () around the conditions and place the ! before that to make it work. So I learned something there.
"if you use it right" is a deceptively high bar
if you're a beginner, you will not have the capacity to use it right, tbh.
How to cheat yourself from engaging with meaningful learning material. And be content with LLM spitting out small titbits at you, that you will be so excited to find another part of that bit in another random answer. Instead of learning the whole thing from the source at once.
i want to implement sword attack in my game so should i attack collider to sword and also should i make sword child of my hand for sword to follow animation
smh.
I think you underestimate how many people learn really awful habits and outright lies instead of actually learning
like there's tons of people who directly come in this server as a result of it
there's a lot of ways to achieve it, that would be one of them, sure. it also depends what your project is (what perspective/context, what genre)
it's kinda action adventure 3d so according to that what would be best
there's no best, period
what you suggested could work though
you could go with that, or if you think there's a better way, try searching around
What other people do isn't my concern. I spent some time on Google looking on better ways to use If/conditions and didn't find the formatting I was specifically looking for to do it correctly. Another avenue worked and now I can use that knowledge to know how to and write conditions in other ways and much shorter. But drops it. Whatever. I'm dumb and none of us can use tools adequately.
okayy thanks
A couple of different ways of doing melee swings -
- Don't use colliders at all. You could just distance check and then do some calculations if you need to at the end of an animation. (Akin to runescape, dungeons and dragons, where its more about stats than physical collisions)
- Use a box collider in front of you. Then do some checks at the end of the animation if anything was detected.
- Attach a collider or shape cast to the weapon. This would be for some systems that may need to know which body part was hit, more precision, ect..
Many different ways depending on what your combat is like, requirements.
@pliant lion
What other people do isn't my concern
Ok well this is a code support channel so if someone does give out a poor recommendation people are going to reply with disclaimers because concern for other people is the kinda point here
To illustrate how much of the information you are missing. Instead of getting a narrow answer you should look at an actual manual page of the ! (Unary logical negation operator). https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/boolean-logical-operators And get a wealth of information about its usage and other operators as well. And while you may not remember everything, you would remember that such additional things exist and where to find them. This is what you are losing polling LLM instead.
You see, the solution being private List<string> TextToDisplay = new List<string>(); was not helpful because the only lists I've had to make in the pathway were all public so I've never had to do this before.
When all the lists I've had to implement before just look like public List<GameObject> targets, I don't have the knowledge inside my head to make connections about why my list is giving me a NullReferenceException, and just telling me to know better is not helpful.
okkk let's not extrapolate the wrong thing
do the pathways not cover the concept of null or instances at all?
and just telling me to know better is not helpful.
you gotta stop pulling these things out of thin air, man
Not in meaningful ways, no. They're words that are said, but not expanded on with exercises to demonstrate it.
When interacting with learning material, it's up to you to take extra steps to understand it. If you do just bare minimum this is the result you get.
If you see the usage of something under different context - look it up!
sorry to bother you but every tut Ive seen used .velocity which has been removed in unity 6+ and Idrk what to do
it's been renamed to linearVelocity, you'd use that instead
so you've seen "null" multiple times so it's clearly something important
perhaps this is something you should look up to research further 😉
oh ok
i am following a tutorial and this appeared out of nowhere and i really hate it (I'm talking about the clipping when the camera is not even close to the objects)
How do i fix it?
Not a code question. Press F to focus on the scene camera on the selected object.
thank you so much!
didn't know if it was code related i'm pretty new to unity
Hello! Am really sorry for disturbing, anyone can help about moving my character? I can move my mouse around but my character dont move, like it doesnt have keyboard input or something. There is the code, I dont think i messed up anything serious. I really need help about that to continue my project.
debug the inputs and find out for sure
Debug.Log($"Horizontal Inputs are: {moveH}");
Debug.Log($"Vertical Inputs are: {moveV}");
or
Debug.Log("Horizontal Inputs are: " + moveH);
Debug.Log("Vertical Inputs are: " + moveV);
sounds good, where do i paste that? or just around the code?
oooo, okay okay lemme try
using Debugs is a good take-a-way from this...
never assume codes doing what u expect it to do..
logging messages and variables in the console window when and where something's supposed to happen can confirm
okay so it came out it has keyboard input, since the numbers are changing depends how i press them
so wasd stuff works, what coming now?
yea.. for GetAxisRaw it'll either show -1, 0 or 1
yep, thats exactly that happened
well that means ur Inputs are working...
and it must be something else
hmm, where do i start?
wondering if Debug.Log() would work
but if theres no console error and all works, the error am searching just slips thru
you'd want to log the values ur using for the movement
make sure those are working as they should.. and then if thats the case it may be something else.. maybe the setup..
maybe the forces/ or speed multiplier ur using is too low...
rigidbodies have friction.. if the forces aren't strong enough to move it it wont move..
you can also log the velocity of the rigidbody after ur move logics
something like Debug.Log($"RB velocity: {rb.velocity}");
maybe it's very stupid question: does GetComponentCount() from gameobject reference is still slow to call quite frequently as is GetComponent<T>() or similar calls? like, does it still iterate trough all components every call (like GetComponent does) or it's only changed on add/remove component and cached internally?
also make sure u don't have any other errors or warnings in the console window..
if theres an runtime error or something sometimes it can keep the rest of the code from running the way it should
it seems logical to me work like I wrote with caching, but I don't know for sure if it like that in the engine, lel
Unity's pretty good at optimizing itself.. from what i read GetComonentCount() is designed to be more efficient than creating new arrays like GetComponents().Length
Unity internally maintains the component count so calling Count shouldn't need to iterate thru all the components each time
i'd think you'd use it where you need to know the number of components attached to a GameObject without actually needing to accesss the components themselves..
never hurts to Cache things yourself tho..
if you have something thats repetitive.. make it a function.. cache it before hand... use whats cached whenever possible
Today I learned, tbh
didn't know that function existed
but if theres no console error and all works, the error am searching just slips thru
-# here's a little tip 👇 you can toggle "Collapse" in the console window and it'll make similar logs Stack so its easier to see whats going on
hi guys i really need help and i need an video to record this
I never had something like this in my life
wait is it only on my Pc laged the video? :(
Pls ping me if you have an idea
imma try that out
i using default rigidbody
well not sure but the camera is the wrong thing to be selected there..
when u stop and u continue to spin.. the camera's rotation isn't rotating
soo it has to be up the hierarchy
i cant tell whats going on
well my console is kinda much empty haha
thats fine and dandy... even a default rigidbody wont move if the forces arent enough
Okay so i interact with anything in my game and the camera is glinding a way like going on ice with 30Kmh
for example if i do rb.AddForce(vector1); it wouldn't be strong enough to move it
at all
Oh okay so the capsule is gliding not the camera
well not sure but the camera is the wrong thing to be selected there..
when u stop and u continue to spin.. the camera's rotation isn't rotating
What should i do against this?
its not the camera... look at the Transform inspector when u start sliding away
its not moving.. so it has to be the ^ player or something above it
Yes it is my invisible Capusle
CAPSULE name = PLAYER
But what is the problem i mean why is it doing this?
Because it isnt in my script
movement code.. u should change it...
see whats happening.. (it appears that some vector or something is continued to be fed into it)
and if thats not the case.. maybe its b/c u are actually sliding along the ground...
Okay thank you i am looking
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
may need to do something in the movement code when ur not giving it input
if(input) -> move
if(!input) -> make stop
A tool for sharing your source code with the world!
debug the values that u use for ur movement... see if they correspond to what u think should happen
yo i am doing this now
the more info the better, but i must step out 🍀 goodluck
now all got stuck lol
and theres no error line in the console
putting a Log in there wouldn't stop the code from working like it was before..
it would just log a line to the console in the meanwhile 🤔
it did the log, but after when the input logs started working they are stuck in one position
thats b/c they stack on top of each other
probably because it disappeared, yeah
i start to get it but i dont at the same time
tutorials are just literally putting the cam into the capsule, pasting in the code and tada it works
did u try cranking up ur Speed/force multiplier
see if it moves w/ a greater force..
also check if the constraints aren't set to Lock it in a specific axis
do you mean me?
its b/c u disable ur movement script
and <insert weird something something that forces u off to the side>
yes but i needs to be so the player dosent move when he is farming
okay let me check
you should instead wrap ur movement in some code or something and turn a boolean on and off
canMove = true / false; for example
and instead of disabling the entire script just set that bool to false
Oh yes thank you good idea
How do racing games handle AI? I tried implementing it where the AI follow a spline, each node on the spline has a predetermined throttle and breaking percentage. It works but then it all falls apart on the first turn of the 2nd lap since the cars moving faster since its a hotlap and additionally it takes an eternity to tweak each nodes breaking/throttle values.
sorry for ping
public class SimpleMovement : MonoBehaviour
{
public float speed = 5f;
public bool canMove = true;
CharacterController cc;
void Update()
{
if (canMove)
{
float moveX = Input.GetAxisRaw("Horizontal");
float moveZ = Input.GetAxisRaw("Vertical");
Vector3 move = new Vector3(moveX, 0, moveZ).normalized;
cc.Move(transform.position + move * speed * Time.deltaTime);
}
else
{
// some other movement code to keep u in place
}
}
}```
so instead of simpleMovementScript.enabled = false
just do simpleMovementScript.canMove = false
b/c i don't know exactly whats wrong with it..
but the video is proof
when its enabled -> it works
when its disabled -> yeet
imo the best ones use sensor arrays
vision cones etc
so they're basically driving.. not following a pre-determined path
cuz thats boring 😄
you can probably even make a hybrid of the two.. (so if it can.. it'd follow the spline)
and then when it needs to.. or its disrupted it could actually drive itself
until its back on track to rejoin the spline
sounds easy enough 🫠 ¯_(ツ)_/¯
unity is not powerful enough to handle this 🙁
12 cars firing off 20 raycasts/spherecasts etc wont run
had about 15 up front and a few raycasting down to get the surface type
but the walls were basically "bumpers" like old-school Ridge Racer 😅
I have the script but i dont see it in the inspector can you take an look poof?
unity can handle thousands of raycasts / frame
I will give it a try
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
A tool for sharing your source code with the world!
its cause you're disabling the capsule collider
idk why you're using a capsule collider and a player controller on the same gameobject
already told you how u can solve it
and yea... this thing is doing nothing but getting int he way and making things more complicated than they need to be
this is the Collider and the Controller
you should instead wrap ur movement in some code or something and turn a boolean on and off
canMove = true / false; for example
and instead of disabling the entire script just set that bool to false
so instead of simpleMovementScript.enabled = false
just do simpleMovementScript.canMove = false
b/c i don't know exactly whats wrong with it..
but the video is proof
when its enabled -> it works
when its disabled -> yeet
CC's dont like being enabled and disabled..
I feel like if he removes the capsule collider his problem goes away
but i could be wrong
Hey im trying to use VsCode and ive got a few extensions from a video I saw, but idk if they have different settings but some of the Intellisense stuff just doesnt work quite the same for me. For example in this one doing Transform. doesnt bring up any options for me to do after that? and then the second image doesnt have stuff like the purple game objects n all that
so i added a line of making the object force to do a move..
||it didn't moved a bit||
thats all i get too
try something like Transform.
any reason you're just not using visual studio?
Never coded before and not sure what the difference is/whats better to use
u should grab this extension
b/c VSCode is better 🤪
neither is really better, they're just different tbh
I do have that, but it just isnt working the same
vscode works fine
make sure to configure your ide
!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
• :question: Other/None
I believe mine is to my knowledge, I have it set in unity to use VsCode at least
Yeah after you find the right combition of extensions to make it work, or you can just check a box when you're installing the editor and get a fully featured ide by default.
they're different. the abc icon means it's just pulling tokens rather than being aware of the context
ahh cool
it's literally just clicking like, 4 buttons
make sure to actually install .net too
command palette -> install .net system wide
does vs code support debugging?
i lose track now-days with the AI the snippets, and just the Extensions in general getting better all the time
breakpoints and reading variables while running the game
ya, with the C# devkit + debugger and stuff
vscode the ide itself supports those, but not sure about with unity, i don't really use debugging in general lol
i should do that more tbh..
hi @rocky canyon i have made this like you did but i doesnt get shown in the Inspector PLEAS help i dont know xD
i just troll a bit... (i use vscode because i do hardware embedded development as well)
its easier to use 1 ide for everything
what doesn't get shown in the inspector exactly?
exactly! i never understand the hype over jetbrains' suite lmao
You didn't make it plublic
^ my guess as well 😛
an entirely separate ide to configure for each language? that's insane
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 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.
and have you saved and recompiled
then u have compile issues...
A tool for sharing your source code with the world!
theres really no need to summon the bot everytime u want to post code...
Just did that, but not sure it changed anything lol
use a bookmark or write it down homie 😄
bookmark?
You know what pmo, jettbrains has a C# and C ide but the workflow for C projects in the C# ide is completely different than in the one for C so if you work with pinvoke a lot the more efficient workflow is to code your c in CLION and your c# in rider.
ffs
u can check ur .net tool in the output window i believe
I think my issue is some wierd intellisense setting tbh
What do you mean?
his question has been answered 3 times and hes still trying to fix it another way. All he litterally has to do is remove the capsule collider from his CharacterController gameobject
exactly lmao, and then vs just supports some languages and doesn't support others
make sure you have No Problems
Debug.Log($"asdf { a * b * c < 0 || x || y * z }"); <-- bad
Debug.Log($"asdf { a * b * c < 0 || x || _y * z_ }"); <-- better
@cunning bramble This is not formatted. At least check the pin you keep summoning . . .
Okay so i remove the capsule thing?
that was what you were told to do several messages ago, yes
That will most likely fix your problem
you don't need (2) colliders especially when they're overlapping
make sure it installed successfully
the CharacterController is a collider
Believe it did, it said done in the command area at the bottom
and chances are the two colliders overlapping is whats causing your weird slidy behavior
alright now reload window (restart vscode or via command palette)
Ahh alright
Yep that fixed it, it seems
tysm, would not have figured that out lol
The simple turning it off and on again
this has consistently worked actually. wonder why these aren't described in the config instructions
Yeah funky stuff
(also why doesnt it just auto do it if its needed anyways)
guess the same applies to IDE's too 🙂
oh they are mentioned in vertx's instructions
welll its not always needed
I can write my HTML + CSS (webdev) in VScode.. and i wouldnt need any of that crap
Hm true
its modular..
vertx's is much clearer than microsoft's, damn
because vscode is not an ide, it's just a really extensible text editor (that comes with enough built-in extensions to act like an ide)
Ohh okay that makes sense
Okay so i removed the character controller but now i get 100+ error messages so my idea is to complettly delete the capsule or only leave the capsule colider
More open-source n all that too which I do enjoy
we just force it to work as hard as
does >8)
im a sucker for the UI + all the extensions
yeah if you were trying to use the capsule collider in code then that wouldn't be possible anymore

leave the character controller on the script and take off the capsule collider.
ahhuurrmmm okay
not sure why this is a surprise to you
like are you trolling us right now?
ok fr.. im stepping out this time
we all tell you remove capsule collider and you took off character controller
aint no way you''re being fr rn
NO i am just over used today xD i mean i am doing this like since 14 hrs or so
This is what happens when you try to jump head deep in development making a game tbh
is there an area for C++ in this one?
gotta learn the fundamentals
can't really use c++ with unity, so no
yes you can ask your question
rip
like 40% of my codebase is in c/c++
c++ would be offtopic, find a c++ related server or DM them
the engine supports c++ plugins it wouldn't be offtopic this is a code channel not a c# channel
Okay works now... 
no, its not related to unity, im doing visual studio
then why are you asking in the unity discord
jesus chris, its because i wanted to know if there a SEPERATE AREA FOR IT
that all im asking
aightt you got your answer we don't need to prolong this unnecessarily
you should be able to find prominent c/c++ servers just by googling
if not that, then general programming servers like tph or tcd
alright
(for future reference, this entire server is unity-focused)
how much code was this lol cause honestly thinking about it in my head this is going to be a lot lol. Gotta code raycasts to keep the car from hitting the wall, keep the car from hitting other cars etc etc.
little more than 1000 lines iirc

the rays in the front were to tell the car if there was another car in front of it.. and how closely to draft it
the rays on the outsides worked differently... the closer to the middle would steer it more aggressively than the ones on the outside.. and i think i also had trigger colliders (like spheres) around it as well for "proximity" type sensors
and also i used "ghost" cars.. so the car would "project itself" forward depending on its speed... and all those combined would make the decisions.. then it was all about that fine-tuning of values..
steering angles, the smoothing between those angles.. accel and de-acel speeds and so on
they weren't very "competitive" tho ngl.. i was just happy they made it around the track on their own 🙂
if i had kept going i probably coulda made it more competitive and drive more aggressively.. but it was really more of a proof of concept (using sensor arrays like a self-driving car would) sonar, lidar, so on
not mine.. but it was very similar b/c i also used gizmos out the wahzoo
https://www.youtube.com/watch?v=OQps_DfIep8 watch some devlogs
In this video we will be making a controller for our car that drives on it's own so the player can compete against the AI drivers.
Join our Discord:
https://discord.gg/cgmnF2edTp
Github Link:
https://github.com/Nanousis/NanousisCarController
TimeStamps:
00:00 Intro
00:39 Learning Racing Lines
03:12 Creating the waypoints
04:00 Braking Zones
0...
see how other ppl do it
Do you guys like it at the moment? (I use the free icons as assets for testing purposes; Terminal, Explorer, Folder icons)
Just need drag and drop from Desktop to Explorer grid and vice versa now xD
ohh and waypoints.. i forgot to mention.. it would use waypoints to know which way to go around the track..
but it wasn't a spline.. it had to figure out how to get to the waypoints on its own
Oh gosh how to post video link correctly?
So how did the car know when to break when the raycasts infront were no longer hitting the road?
https://streamable.com/i9njbe
Is this okay? Sorry. It created raw link hehe.
no i had barriers.. there was always something in front
but it used distanced + speed + the raycast hit
my rays were basically infinite.. (i didn't really cap them..)
it was more of the switch statements and conditionals that were always checking the hit comparing the distance all that
My project is like an OS hacking game with NPC's, networks, players etc hehe. Like Grey Hack eventually. Inspired by that.
I also have a 2D skilling game project with login and register support with NodeJS server yay. Excited
hmm ill probably have to handle it a little differently, my tracks are not flat so sometimes there may not always be a hit
but like if the hit was way way out in front the code would just ignore them
Thanks for all the info
ohh thats true.. thats another thing i hadn't considered
would be the hills and peaks and stuff
this gives me a good general idea
guys.. I imported a character controller asset, without touching it the character keyboard control still doesnt work...
could raycast up into the sky for a good portion
i think am going insane
Or raycast down doing a check for the ground if you put one in front of the car
u can use a system like this + waypoints + triggers and stuff to come up with a pretty decent AI driving
this is the error it got
ya... u can't call Move() on a CC thats disabled
lol... if ur CC is disabled.. u might want to run a check in ur code to see that it is
Anyone interested in such a project? In-game OS system with functional terminal, custom caret, etc? 🙂
Almost have file system and desktop stuff completed.
For potential colab?
I get lonely coding alone.
b/4 calling that function
isCCEnabled -> if so we can Move()
isCCEnabled -> if not we shouldn't call Move()
!collab
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• ** Collaboration & Jobs**
I'm willing to help out for sure, but as I'm working on my own personal project it would be difficult to split time
Oh gosh sorry. Thanks xD
no problem 👍
what
If this is not enabled
No rush at all! Sometimes I take a day or two off from it. I just know that it has potential. 🙂
I shall drop you a message my good friend.
then the script thats calling Move() gives u this error
it works with rigidbody
FirstPersonController.cs line number 117 which is the Update() loop that calls ur Move() function or a method with that function
line 198 is probably the Move() function..
u can't call that on a CC component that is disabled
ya they're not always accurate
how can I play a gameObject's animation to its end to make a vfx? its a 2D game
but its around-ish
i downloaded that asset
https://assetstore.unity.com/packages/3d/characters/modular-first-person-controller-189884
and i literally just pulled it into my project
no clue then.. you'd want to ask them.. hit up their support
https://assetstore.unity.com/packages/tools/physics/kinematic-character-controller-99131?
this is the one i've used in the past
ya, thats alot of code to look thru for an error thats someone elses fault 😅
if ur using the prefab they have in there there shouldn't be any errors..
else thats a crap asset.. i'd reach out and check or see what teh comments say about it
w8 new error appeared
bro are you not reading the error?
this has nothing to do with code as you been told
ya, same error.. it means the same thing... https://discussions.unity.com/t/charactercontroller-move-called-on-inactive-controller/674532
i think they're "winging it" as far as they can
click on your player look in the inspector you got a component disabled
#💻┃code-beginner message as said
that would be funny, since i still literally just pulled in
didnt add or disabled anything
bro its a free asset you cant expect it to be good
yea.. but u gotta start using critical thinking..
it may be possible.. that its accidently disabled