#π»βcode-beginner
1 messages Β· Page 674 of 1
sry if this is a commonly asked question and also sry for my eng (not my nativ).
i'm searching for scripts or a tutorial for a 2d turnbased battle like ff but evrything i found is to old or not completed i hope someone can help me out
this are the features i need just in case its importent:
- out of comabat member switch (party manager)
- attack, skill, magic, item and escape buttons (ui is alrdy done)
- skills use sp magic mp
- skills deal physics dmg and magic magic dmg (this one is not neccesarry if to complex)
- also the player can switch classes out of combat (if this is neccesary for combat)
- i also alrdy did scriptableobject for classes, items, skillsMagic, equipment, buffDebuff and enemys
- also i have a skript to store each class for each individual member of the party and a runtime script to store the actuall data like current health etc.
*also called sideview battle
also why is the score manager relying on a specific Alien anyway ?
alienHeath = GetComponent<AlienHeath>();
you're looking for AlienHealth on an Alien object itself in Score ? when you destroy the gameobject the Score also goes in the 
public Text score; this is pretty misleading naming. score should be scoreText while the score itself should be int variable
so that why
thats why what?
how many Aliens are going to be there anyway
okay so I guess that means more than 1.. so you definitely need a different way to do this.. You should not have Score script per enemy..on the enemy..
i made the aliens a prefab so they all have the script
right.. they all need 1 reference to Score and when they die just call an AddScore() method on Score.cs
put custom value if its more than 1 AddScore(3) and so on
okay
There isn't gonna be a tutorial or free collection of scripts out there for every single feature you want in your game. Break down each feature into steps, and then figure out what youre struggling with.
i know but at least a basic, as said all tuts i find are old and not rly usable for me cuz they use or reference stuff which dont exists anymore or is obsolete
You can do most of those with basic coding fundamentals. You can probably find a good tutorial by search up how to make a turn based rpg in c# instead of trying to search for unity tutorials
Use more descriptive searching, break down the system you want into smaller parts, and search for that, or use the tutorials and change the outdated part(s). I'm curious about which part(s) are obsolete . . .
Shouldn't the slider be giving me here a choice of assigning the method but with the value of the slider instead of a manually set one??
try method with float see if it shows under Dynamic
Oh, so it only catches floats, even tho it's marked as whole numbers
Weird, but ok
you can see the type right there
OnValueChanged (Single)
yeah it doesnt change its type does some internal clamp i think
So, basically a float?
yes
Marked as whole numbers indicates the value is clamped, that's all . . .
The actual value is a float . . .
im trying to publish this vrc avatar and this error keeps popping up, I looked through the assets folder and there was nothing, it seemingly doesnt exist and stops me from trying to publish
is it possible to attach separate parts of 3D objects in unity it triggers animation? Example i made a script of attaching parts for a robot. I just need to make it trigger a custom animation when all parts are attached. But my parts are mix and match basically variations of different parts can trigger the animation
sounds like a question for #πβanimation
Hey everyone, I'm trying to learn fundamental of game making. I was following this playlist to understand basics
In this Unity tutorial we're going to look at how to allow the player to shoot and destroy enemies
This is the seventh video in our series showing how to make a full top down 2D shooter game in Unity.
The playlist for this series can be found here
βΊ https://www.youtube.com/playlist?list=PLx7AKmQhxJFajrXez-0GJgDlKELabQQHT
The project files a...
In the end I figured out something
In the code he always creates bullet but never destroy the gameobject of bullet
I tried to destroy in this script but didnt work well
I was trying to get game object of bullet, I dunno how it works actually
you're destroying the prefab not the spawned bullets
yeah but how I access the spawned bullets
shouldn't I access prefab first in the code?
you only need to access the prefab when instantiating the bullet. the prefab has no connection to the instantiated objects. the Instantiate method returns a reference to the spawned bullet, but presumably you would want to handle destroying them from the bullet themselves. so you destroy the bullet gameobject from the bullet itself on collision or after some time
and if that OnTriggerEnter method is on the bullet object but it is never being called then go through this: https://unity.huh.how/physics-messages
that makes sense
yeah got u
So basically we getting enemy movement component if its trigger we destroying the object of zombie
I mean collision
between two object
did I understand correctly or
go through all of the information
she made it in the next video
She actually taking the camera checking the position off camera if camera.x < 0 || camera.x > camera_pixelwidth same for height and then destroying the object
I just wondered a thing in this code now.
If we destroying the gameObject in this code, so we actually destroying the object of Bullet then, right?
I think I figured out now
Any c# number type good to use for idle incremental game? I want something that write 1,000,000 as 1m and so on. I don't want to write it myself
BigDouble is nice for big numbers (also comes with a built in property drawer), but it doesnt do alpha suffixes
those suffixes aren't really standardized beyond trillion (and even then casing isn't standard)
so there's not gonna be a built-in for that
I mean some games just have made up system
exactly
commonly starting those numbers they do a
they do the stringification themselves
or maybe there's a library for it
but it's not gonna built-in because it isn't a standard system
ugh I dont really wanna write that, but whatever, I guess I have to
You dont actually need to store the large values, and you shouldn't. You just store let's say up to 4 digits, and every time it goes above a certain threshold you change to a new suffix.
This is probably one of the easiest systems you could create too. Its just a list of strings
999 no suffix, 1000 = 1k. 1000k = 1m. Onwards
it's easy yea, but will still take time, but sure, I think I have to
hey, more experience in logic
practice the small things so you can manage the harder ones later
Unless you mean it takes time because you arent familiar with c#, I dont see what here could take that much time. Its really just a list of strings and checking if the current number is >= 1000
i mean i don't think that'd directly work
the games he mentioned usually have quite dynamic shifts in this, treating it as if it were a really big number with detail all the way down
buying something when your money is close to the cost doesn't bring you down to 0, and commonly a few decimals are shown eg 1.5k or 3.2m
so there is a bit more nuance, some system to design out for UX
All of that is still possible through the same idea. You dont need to store insanely large numbers, its just a computational waste when deep into the game, you have 130 trailing zeros on each number
Store 0 to 10000 then and suddenly you can still represent 1.5k
im not saying it's not viable with you idea, just that it requires more thought
it's not just figuring out how to do it, it's figuring out what to do in the first place - as in, what the requirements for the system are
how many digits should be kept? does that achieve the desired effect? etc
also of course you still need to be able to tick up if you add a small amount a lot of times
π€·ββοΈ the thought is quite simple. Probably easier than trying to create a system working around arbitrarily large numbers and having to fix performance issues down the line. I dont see how any of this affects the overall idea that you shouldn't be storing the extremely large numbers. Games dont store the large numbers
im not saying to store arbitrarily large numbers
my point is there's more nuance to the system, you can't just hand-wave all the details away π
youre destroying the prefab
Destroy(gameObject) fixes it
Sorry i'm just a bit confused here, what does this mean my script doesn't derive from monobehaviour? It has the mono behvaiour at the top of the script so im confused
do you have any other scripts on that object?
any child objects?
can I see a screenshot of the inspector?
The only other thing i've changed is that i set is trigger to true so i don't forget later
Also for some reason the object is showing up blue on the screne but thats it
that is really strange π€ have you tried removing the script?
Still shows the same error
yeah it's not that script then π do you have any other scripts in your project?
Nope, that is literally the only one
Oh i just noticed something, does it change anything if it says the object is a .prefab?
have you tried restarting unity? π
I dont know why its saying its a .prefab
Just did and the object was just gone cause i forgot to save π
oops lol
but i made another
working now?
sounds like it was just unity having a bad day π¬
@split plover did you have any compile errors
Is it normal for 3d objects i drag into an assets folder to not change positions
I don't think so
it sounds like something hadn't been refreshed to me
drag from where?
when i change the position and the object is selected it doesn't change positions
that's what prefabs are, gameobjects in .prefab files
just the character folder i made for it
Whats a prefab?
π
because it's a prefab, not attached to anything in the world
a prefab is like a blueprint, it's not actually in the game it's an asset
oh
the one in the scene is an instance of the prefab
aight you should probably go through unity essentials
!learn π
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
well if its planning to be a parent object should i still have it as a prefab
prefabs are typically used for:
- objects you want to spawn during gameplay (e.g. enemies that spawn in)
- objects you need to reuse frequently (e.g. trees or rocks)
Okay but quick question should i use prefabs if i'm planning to use the object on different maps and stuff
yeah i want to spawn it during gameplay
go learn what prefabs are and it'll answer itself
@split plover have you played minecraft
well i dont wanna learn something i wont use but alright
no
(you will need to learn how to use prefabs)
unity essentials are pretty much required
they're essentials
you should play minecraft there's a lot of good comparisons using it π
prefabs are a very common part of unity development. Do the unity essentials course, it teaches you the stuff you'll need!
sure, skip over 2d and audio and publishing if you aren't doing that now
but you will still need the essentials for whatever it is you're doing
the 3d essentials mission goes over prefabs
go learn
Well i'm not really planning to release games
that's why i said to skip over them for now
just making a game i can play with friends
...that still requires publishing
wdym
publishing is turning the project into something you can actually play
im just planning on sending the game files over off of like mediafire or something im not planning on putting it on steam or something
i think im confused
if you don't want to publish it publically, sure, but you still need to publish it so other people can play
publishing is how you get the game files
right now you have project files
I thought publishing was like, posting it on something like steam or epic games
those are some platforms you can publish on
ok
anyways that's all irrelevant for now - right now you're still in the process of making the game
you will need to go over essentials for the topics you're working on
im watching the essentials introduction right now
amm i able to fully skip the install unity tutorial
i feel like i should be able to but im not sure
just in general for stuff you already know, i'd recommend at least skimming just to make sure you aren't missing anything
alright
another stupid question but i was reading the unity docs for why the input system wouldn't work and when i try to use InputSystem.actions it says it doesn't exist in the context
it has using Unity.VisualScripting.InputSystem and using UnityEngine.InputSystem at the top so idk whats wrong
im just gonna use the old input system idk why it wont work
What version of the package are you using?
The only one it showed in the package installer and the one that came installed
Which is?
you most likely don't need Unity.VisualScripting.InputSystem. remove that.
Should be fine then. The visual scripting namespace is irrelevant and should be removed
give more info please - what code are you trying to use, and what's the error you get?
c# and i said im getting an error that says it doesn't exist in the context
that doesn't give me any info at all lmao
It would be best if you posted both the code and the error as they are, not second hand descriptions
Okay
show the exact !code and exact error, not just your retelling
π 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.
its not like im lying or anything
its exactly what it says
Can you hover over InputSystem and show what it says
And also send The surrounding code so it's clear what you're actually doing, not just the error in isolation
isn't actions for the new input system? It won't show if you don't have the project set to use new input system in the project settings..?
I have it set to both cause im currently using the old one since the new one wont work for me
using UnityEngine;
using UnityEngine.InputSystem;
public class MovementScriptBaseCharacter : MonoBehaviour {
public float movementspeed = 5f;
public Vector3 dir;
float hzInput;
float vInput;
CharacterController controller;
private float gravity = -3f;
private float velocity;
[SerializeField] private float gravityMultiplier;
public float velocityMultiplier;
void Start() {
}
void Update() {
CharacterMovement();
}
void CharacterMovement() {
hzInput = Input.GetAxis("Horizontal");
vInput = Input.GetAxis("Vertical");
dir = transform.forward * vInput;
dir = transform.right * hzInput;
dir.y = velocity;
controller.Move(dir * movementspeed * Time.deltaTime);
}
InputSystem.actions
}
thats the code
you're hovering over the error, hover over the class until it shows a window about what it is
it's not inside a method
it has a bunch of stuff that i haven't put in the code yet
If you hovered it it would give info about the class, not just the error
cause im still coding it
ok InputSystem.actions is outside statement blocks.
wdym statement blocks
{}
it needs to be in a method/prop/constructor/init block
it can't be used in that context - the error says there's nothing matching InputSystem.actions that fits in that context, it'd have to be a type/namespace
just how c# works - you can only have declarations and definitions directly in a type's body (eg a class, in this case)
statements have to be inside methods or similar
C# isn't a functional language, you need to define a scope for things
A class, even static, and a method to call. Everything has a path here.
Otherwise ask Unity devs to support F# π
!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.
how hard would it be to make procedurally generated buildings with interiors, loot, furniture and set it to an area? I'm trying to make a urban area that has random buildings in the middle of the playing field, and I'll use a bunch of buildings together as a barrier and ambience
It would be easier to just make prefabbed layouts and randomly pick them rather than procedurally creating everything from scratch.
That said, most games fake the interior through the windows with a parallax texture. Its overkill to actually put real props inside something you can't move around in.
hi guys i just started not long ago and i want to ask why when i first initialise a value
public float speed = 20.0f;
public float xRange = 15f;
it saves the value into unity but when i change in vs ide it doesnt update unity
oh you gotta change the value in unity
Since those variables are public they are serialized and saved in your scene file
this is basically just the initial values
Once they're saved in the scene file they have to be changed in the scene
from there forward it follows the values you set in the editor
If you don't want this behavior don't make them public
oh
plus, it's generally bad practice to set fields to public
so to allow changes to update from vs i have to make it private?
[SerializeField] private float speed = 20.0f;
Or set the values in Awake
but if you do want to expose the value to the editor, use this
That won't change the behavior they're asking about though
Since that will also be serialized
mhm! but just throwing it out there
awake as in the void Awake() method? if i initialise it in their can i access using other methods also
like Update()
Why would initializing it there affect that?
yes that method, if you initialize it in there, no other method can access it tho
if you want the update method to access it, you must set it as a global variable
The fact that it's a field is why you can access it in all your methods
It's not a global variable
It's a member variable
wouldnt the scope change or smt like that, i have a bit of python background so i know a bit about that but im not sure in c#
I'm talking about assigning a value
Never said to change where you declare it
ohh
wouldn't the access be limited to the Awake method if you declare it in the awake method?
You must still declare it outside
this
It's just he might put the entire code in the awake function
i understand now thanks a lot guys
there's a nice 10 hour course on youtube for basic - intermediate btw @mossy nimbus
it's project based, too
after you're done with the course, you'd have created a pretty nice game
im following the guides on learn.unity.com but it seems like their player input system is the old one, i will be sure to look at that
thanks
mm! This course teaches you both the old and new input system
and you'll learn code practices that's very essential
oh and it's free
its the one from CoffeeNCode?
Quick question, if the input system is so hard to use why do people say to use it over just keycodes
changing the inputs from keycodes to input system genuinly added nearly an extra 10 lines of code π which is a lot when it was only 20-30 before
Hey, I need help with something, Ive been trying for hours now... im making a tower defense in 3D, the thing is, im making some code so you can upgrade the towers, the buttons work with building them, but ive tried a lot of different things and the function doesnt even react like im calling it, could someone hop on a call to help?
It's only hard to use if you're a beginner or haven't used it before.
You can directly use the new system in a 1:1 way from the old if you understand it well enough
With exactly the same number of lines
Well
But the benefit of the new system is that it's much more flexibile, supports runtime rebinding, and event based handling, et
i guess yeah its not that hard to use but it is still way harder than just keycodes
oh right
people have to be able to rebind stuff
ohhh
Because trying to make a control system that can receive input from any type of gamepad and has customizable controls is effectively imposible on the old input manager, but basically free in the input system
ok well if people want to rebind jump from spacebar then i'm not letting them anyways thats a crime
It's not any harder if you want to use it the same way as GetKey
You can just do e.g. Keyboard.current[Key.A].IsPressed()
That's the same as GetKey
Not any harder to use
just to use it in an if statement i had to make an entire bool for if a button is down after trying to figure out what the fuck an action phase eis
But you also lost all the benefits of the new system doing it this way
i tried using is pressed but it said it didn't exist
Also, using the Input System will sort of subtly encourage you to structuring your code better. Having functions that respond to a specific button instead of a monolithic update class with a cliff wall of if statements
You don't have to make any extra variables to check for an action being pressed in an if statement.
The thing is you are using one specific workflow and the new system supports many workflows
well when i tried just putting if the jump input was in the if statement it straight up said i couldn't convert it to a bool or something
You are still learning and not aware of how to use them all
This is a limitation of you not understanding how to use it and how to use C#, not a limitation of the system itself.
but like, it literally said i couldn't itself
The specific literal code you wrote was wrong, that doesn't mean what you intended to do isn't possible
It just means you don't know how to write it
how else would you write it other than if (playerInput.actions.FindAction("jump"); (used playerInput as a placeholder for the input map)
if (playerInput.actions["Jump"].wasPerformedThisFrame)```
In all fairness i did put a . after it to check if anything like that was available and it refused to show me any auto finish options
Er sorry it's WasPerformedThisFrame()
I guess the only reason i probably wont use this even though its more useful is that my game will have a lot of controls so bieng able to just set it to IsDown(playerInput.actions("Jump")) would probably be more efficient anyways
I have a really weird bug where my vector3.zero and vector2.zero are both off screen to the left. Im wondering if this is to do with using a "scale with screen size" canvas but im genuinely not sure, if anyone could help that would be great.
This "8" should have been spawned at vector2.zero.
it's not spawning as a child of anything is it?
UI elements should be positioned with anchoredPosition. Setting the transform position will have unexpected results
I changed pinsParticleTransform to a RectTransform and used .anchoredPosition to Vector2.zero, and it was still in the same place
I dont think so, when it spawns it spawns like this (if that is what youre meaning)
and is its position (0, 0) in the inspector?
yes
It needs to be in a canvas
omg thank you very much youre a life saver
Why it's so freesing...
using UnityEngine;
public class CharacterMovement : MonoBehaviour
{
private Rigidbody2D pl_rb;
[Header("Movement Variables")]
[SerializeField]
private float acceleration = 10f;
[SerializeField]
private float deceleration = 10f;
[SerializeField]
private float velPower = 0.9f;
[SerializeField]
private float moveSpeed;
[SerializeField]
private float jumpSpeed;
[SerializeField]
private LayerMask groundMask;
[SerializeField]
private Transform circlePos;
private float circleSize = .05f;
private float moveX;
private bool isGrounded()
{
return (Physics2D.OverlapCircle(circlePos.position, circleSize, groundMask));
}
private void Awake()
{
pl_rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
Vector2 velocity = pl_rb.linearVelocity;
float targetSpeed = moveX * moveSpeed;
float speedDiff = targetSpeed - pl_rb.linearVelocity.x;
float accelRate = (Mathf.Abs(targetSpeed) > .01f) ? acceleration : deceleration;
float movement = Mathf.Pow(Mathf.Abs(speedDiff) * accelRate, velPower) * Mathf.Sign(speedDiff);
pl_rb.AddForce(movement * Vector2.right);
}
private void Update()
{
moveX = Input.GetAxis("Horizontal");
if ((Input.GetButtonDown("Jump") || Input.GetKeyDown(KeyCode.W)) && isGrounded())
pl_rb.AddForce(Vector2.up * jumpSpeed, ForceMode2D.Impulse);
}
private void OnDrawGizmos()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(circlePos.position, circleSize);
}
}
the jittering? where do you control the camera?
using UnityEngine;
public class CameraLook : MonoBehaviour
{
[SerializeField]
private Transform playerTransform;
[SerializeField]
[Range(0.1f, 10f)]
private float followSmoothness = 5f;
private Vector3 offset;
private void Start()
{
offset = transform.position - playerTransform.position;
}
private void LateUpdate()
{
transform.position = Vector3.Lerp(
transform.position,
playerTransform.position + offset,
followSmoothness * Time.deltaTime
);
}
}
I think it's basic
ah, you should set your rigidbody to interpolate
(also probably collision continuous)
Thx
does this also apply to root canvases? (moved to #π²βui-ux message)
help, I'm building my first android build, I followed tutorials when I click build and save nothing happens, the save button is clickable but nothing happens, forcing me to concel, there are no errors nothing, Idk what to do
!logs may be something in the editor logs after u try
hey, is there any chat I can ask question about publishing on asset store?
the publisher portal + docs has everything u could possibly need.. whats ur question?
maybe u should ask in #π»βunity-talk cuz this channel is for code questions
oh right. wrong channel too btw.. ^ u can get answers there
can anyone help me out? I'm trying to make it so that while reloading, my gun wont fire like it was, however when trying to implement a simple boolean (isReloading), it just breaks everything, after reloading, it bricks the gun (the ammo and magazine capacity does not get updated and it wont let me fire, I tried toggling on and off the isReloading bool in the inspector but it's still bricked) btw im trying to make my game multiplayer and im using unity's netcode for that
Weapon Script:
https://pastebin.com/2PeWz45P
Player Fire Input Script:
https://pastebin.com/JvipQzQf
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.
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.
Are there any console logs or errors?
nope, i tried setting up a debug log for when its either true or false, but after reloading none of them show up
Place a log in player weapon fire to see if the weapon is reloading.
the bullet was destroying when the enemy is dead somehow I showed the fixed
there is something im missing but im too blind for this π
my first guess is sync issues
like if the server is handling the reload on the server.. but never updates the local clients view of the ammo.. the client maybe see's a stale state
ill look a bit deeper in a second tho π
Make the logs print different useful data. As is, we're unable to tell if shooting or reloading is printing.
^ yea, u need to log specific data.. from all the relevant methods
so reloading and firing?
i like to log everything.. but its up to you.. the more information you and we have the better chance of finding a solution..
- log the input
- log the reload bool
- log the ammo value
- log when the reload starts
- log ammo and values after the reload finishes
- confirm boolean was toggled back to false
u could even add little tags [Client] [Server] [RPC] etc to see whose calling what at a simple glance..
Put a log in ReloadingOver also to see if it ever fires
But as is, it looks like you're still able to shoot after reloading. What's the actual problem?
after reloading, it shoots but wont let me reload afterwards and the ammo doesnt reset to 30 but a magazine gets wasted
Do you ever tell it to go back to 30? ```cs
[ServerRpc]
public void WeaponReloadServerRpc(ServerRpcParams rpcParams = default)
{
if (isReloading || currentMagazineCapacity <= 0 || currentAmmo >= maxAmmo)
return;
isReloading = true;
currentMagazineCapacity--;
PlayReloadClientRpc();
}```
wont matter bc the gun wont shoot afterwards either way, before me trying to resolve this whole ordeal it was working perfectly (it went back to 30)
Right.. but first.. try setting the ammo back to 30 after reloading...
i have this invisible prefab inside every box that places Xs and Os but i want to select a specific unit of the prefab, how do i do this?
because as you can see with a single click all the boxes fill
I'm assuming you would do so in cs void ReloadingOver() // Animation Event attempt { isReloading = false; }
show the relevant code (also it's prefab not prefap)
public bool player1turn = true;
public GameObject X;
public GameObject O;
void Update()
{
if (player1turn == true)
{
if (Input.GetMouseButtonDown(0))
{
Instantiate(X, transform.position, Quaternion.identity);
player1turn = false;
}
}
else
{
if (Input.GetMouseButtonDown(0))
{
Instantiate(O, transform.position, Quaternion.identity);
player1turn = true;
}
}
}
you're currently not checking if you are clicking on a specific area of the grid, you are just checking if it is a specific turn then just instantiating the object at every position this object exists at. you should consider using something to determine where in the grid you are clicking. either by using some clickable object (like a UI button or an object that implements IPointerDownHandler) or use an actual grid (or tilemap) and convert the mouse's *current position) to a position in the grid
This happens because you haven't designed it appropriately. As is, you're spawning an x or o on click with every object regardless if any specific object was clicked.
yes i know, but idk how to choose a specific square
You probably should not be using Update like how you are using it unless you want to go the raycast route
Best to do what was suggested #π»βcode-beginner message
if i handle it like this, it works perfeclty except that you're able to start firing a bit before the reload animation ends
and guess what, I dont want my gun's animation fucking hardcoded because that's just dumb
What happened to your previous reloading system? The animation trigger event.
i removed it, i tried first implementing that, didnt work (because animations are playing exclusively on client side, how is it going to send information to the server?)
then i tried the boolean route, same issue
something is holding this shit by a thread, and idk what that is
Just send a signal after the animation finishes to update the value on the server?
I think you're trying to do to much and not focusing enough on individual issues
void ReloadingOver() // Animation Event attempt
{
isReloading = false;
FinishedReloadingServerRpc();
}```where that function would check if it isn't this player and update their values or whatever for the gun/player/etc. I'm not sure how others would differentiate who's reloading or why they'd need to know but I guess it might be important to avoid cheating etc
like this?
i'm lost
i've been at this way too long to the point im getting lost in my own code π
First off, does reloading for the individual player actually work? As in, does the event get called after the animation completes? (You should not be able to fire as well)
How do we get a random float between 0.0 and 1.0 exclusive with system.random, when I try random.nextSingle (https://learn.microsoft.com/en-us/dotnet/api/system.random.nextsingle?view=net-9.0#system-random-nextsingle), it is not recognized by unity and random.nextDouble give me a double, I dont want to convert this number in float, since I need to do this very often
Why not use Unity Random that's specific for floats?
also unity has Random.value already a 0-1 value
Yes but the range is inclusive, and I dont want that
what do you mean by "not recognized by unity"?
unity doesn't recognize anything. code compilation is the realm of c#
show what code you used and what error you got
I use visual studio with an help tool I guess, and random.nextSingle() get underlined in red
show what you wrote
π 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.
Applies To
.NET 6,7,8,9,10
none of which is supported by unity
oh, of course, this again
make sure to set the docs to the .net version you are using to avoid stuff like this
NextDouble seems to be available though, could just cast that to a float
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using System;
public class scriptMountainGeneration : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
public Mesh mesh;
public List<Vector3> vertices = new List<Vector3>();
public List<Vector2> uv = new List<Vector2>();
public List<int> triangles = new List<int>();
public List<Vector4> lines = new List<Vector4>();
private int step = 0;
private bool gen = false;
private System.Random random = new System.Random();
private void Init()
{
vertices.Clear();
uv.Clear();
triangles.Clear();
lines.Clear();
step = 0;
}
void Start()
{
mesh = new Mesh();
GetComponent<MeshFilter>().mesh = mesh;
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0)) {
gen = true;
Init();
vertices.Add(new Vector3(random.NextSingle(), 0, 0));
}
if (Input.GetMouseButtonUp(0))
{
gen = false;
}
if (gen)
{
}
}
}```
but yeha boxfriend already answered. that function isnt in unitys .NET 4.x / standard 2.x
Ok, thanks so from what I understand if I want to get a float using system.random I should use (float)random.NextSingle()
anyway if UnityEngine.Random.value is inclusive just omit the included values you don't want with Random.Range
Random.Range(0, 0.9999f) unless you're needing more precision
Since I am making procedural genration with seeds this wouldnt work since unity random seeds is shared all accrosed the project
NextSingle doesn't exist, you can't use that
i'm suggesting (float)random.NextDouble()
but yeah I guess this stays global it would be a pain to change it for each one..
if you want specific things to be deterministic and other things to be random but not affect the main deterministic randomization, this wouldn't really work, no?
I suppose you probably better off making a new System.Random instance for each thing
Yeah, thanks you, that is what I was going to use, I wanted to know if there was any more straight forward solution. I will check later on if I have problem with performance but it shoudld be good thanks
there is this that explains more you can do https://docs.unity3d.com/ScriptReference/Random-state.html but I havent touched i t much so iidk lol
you'd want to maintain multiple Random states using the Random.state property which you can get/set as needed. just cache the current state before using it, change to the state you need, perform your operations, then reapply the previous state after
but just using individual instances of System.Random is likely going to be easier
Nice that answer it for me !
i want too make an object that spawns on an random range but only on multiples of 0.5 i cant get the hang of it i always end up whit full numbers on some objects or weird numbers like 0.375
Show your implementation?
get a random integer and multiply by 0.5f or divide by 2f
there's also the Snapping.Snap method but just starting off with multiples of 0.5 instead of getting a random float and snapping it to the nearest 0.5 is better
Any whole number multiplied by 0.5f should yield some value divisible by 0.5
oh ok thank you guys so much :D
Hey, I am working on programming PacMan in Unity. But now I have the error, that the ghost doesnt return into the starting box, when it should respawn. Here is the code that i have written. Any ideas, how I could fix it?
!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.
and you should probably reduce it to the problematic code, not the entire thing
people confuse this with an ai prompt sometimes
I've made an random spanwer that just spawns 2 different obejcts randomly but i wand that they spawn more like a group like in this image, how could I Implement this?
void SpawnObjects(GameObject Obj, int count)
{
for (int i = 0; i < count; i++)
{
int RandomX = Random.Range(-PlattenSeitenX / 2, PlattenSeitenX / 2);
int RandomZ = Random.Range(-PlattenSeitenZ / 2, PlattenSeitenZ / 2);
float xPos = 0.5f + RandomX;
float zPos = 0.5f + RandomZ;
Vector3 spawnPos = new Vector3(xPos, 0.5f, zPos);
Quaternion rot = Quaternion.Euler(0, 0, 0);
Instantiate(Obj, spawnPos, rot, transform);
}
}
Some documentation would also be nice i dont know the name of this thing D:
So the error is, that it doesnt go in the if statement, cause of the following code line cs transform.position.x == ghostNodeStart.transform.position.x + 0.15f || transform.position.x == ghostNodeStart.transform.position.x - 0.15f , but if I do the same if statement with just the y position, it works. Even without the +-0.15f. Any ideas?
just create a vector3 (as spawnpoint) that you change after every iteration
Don't compare floats directly, use Mathf.Approximately. Your current code will never match because of inaccuracies.
I upgraded to unity 6, and they seem to have changed how the camera is controlled within the scene. I do not have a qwerty layout, and now it is character-dependant. Any way to change that?
this seems like you want to check if it's within a range? what are you trying to do?
what is "an object" here?
a tree? a group of trees for a given tile?
its an prefab from either a tree or rock
so you want multiple tree prefabs to generate together?
ive used
SpawnObjects(Baum, MaxBaumAnzahl);
SpawnObjects(Stein, MaxSteineAnzahl);
yeah
you would probably just pick a random position and then randomly go around that position
or do noise stuff
or have entire patches that you randomly pick to place
there are a ton of ways to do this
If the ghost should return to the home because it got eaten, it should ask, if the ghost has the same coordinates as the ghost spawning point. And if its true, it should return to the box
haha ok im very new too 3d stuff :D
if you're making a clone of pacman, you should probably just have a grid for this, no? then you could check much more easily with vector2ints
Would be a lot to change at that point. The only problem is, that I dont have the time. Its a project for University and it should be finished within the next week
fair enough
you would still have to use Approximately or just use ranges though
seems to me that using a range would just be easier in this case
@jade cobalt
If you want you could try this script I used for a couple of my games. Just attach it to each layer. Note it only supports x axis movement and will loop automatically. If you don't want looping just make sure your image is as wide as the level, if you do want looping copy the image 3 times under a parent object and put the script on the parent object to make sure it loops correctly.
using UnityEngine;
public class ParallaxLayer : MonoBehaviour {
public float parallaxEffect;
private Transform camTransform;
private float startPosX;
private float width;
private void Start() {
camTransform = Camera.main.transform;
startPosX = transform.position.x;
width = GetComponent<SpriteRenderer>().bounds.size.x;
}
private void FixedUpdate() {
float distance = camTransform.position.x * parallaxEffect;
float movement = camTransform.position.x * (1 - parallaxEffect);
transform.position = new Vector3(startPosX + distance, transform.position.y, transform.position.z);
if (movement > startPosX + width) {
startPosX += width;
} else if (movement < startPosX - width) {
startPosX -= width;
}
}
}
Now that you said it idk why it is. I used it a long time ago and didn't see any problems back then.
I understand, I hope they will read it and try to understand how it works so they learn from it.
theoretically it should happen every frame after the camera has updated, so i just put it in a list (dynamically updating upon load) to do callbacks on LateUpdate
spoonfeeding doesn't really promote that, which is exactly the reason why spoonfeeding is not recommended
@jade cobalt Please read it any try to understand it for yourself. Try putting a lot of comments in the code to explain to yourself what is happening, if you don't understand something google it or ask AI.
Doing this will help you learn to code better.
no please don't ask AI lmao
This script is simple enough for AI to understand i think...
AI doesn't understand shit lol
it's definitely small enough for AI to generate something convincing, but there's still no guarantees on it being correct lmao
Or ask here i guess
Code better by never using ai for help π
hello i realized that i need a study partner can anyone be mine i cant code alone
: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
not like this i just want someone to help me
help with.. what exactly?
i dont really know how to code yeat
if you have a specific issue, you can just ask here
there are beginner resources pinned
foreach (MonoBehaviour Child in transform.GetComponentsInChildren<MonoBehaviour>())
{
Child.UseAbilities(_enemyHealth);
}
is is possible to use a function from a Monobehaviour that was defined in the script
bc i dont want to get the script of the child itself bc i will have many different scripts
nvm
i did it
If you want to use a function of a specific script, you're going to need to get that script instead of MonoBehaviour
!learn
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
the problem is that i cant do it
bc it wont work
Why not
That would indeed be what I suggested. You're getting the type you actually want instead of MonoBehaviour
what does what happen?
You didn't explain what is happening?
nvm it still works normally
@rich adder it still works normally so im fine
That just raises further questions
What happens?!!!
What was anomalous about this?
so basically void start is slightly darker like its a custom function
That doesn't help explain what the issue was in the first place . . .
it still works normally tho
Not used/empty i think
its void start tho
if you mean it isn't being marked as a Unity Message then you need to make sure that your !IDE is configured π
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
That means it's not used . . .
It always helps to paste a link to your !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.
i made the script a monobehavior and its working fine now
A tool for sharing your source code with the world!
interaction.WeCollide.gameObject.GetComponent<Rigidbody>().isKinematic = false;
How do I make it so the bool gets inverted if the function is executed
bool = !bool
oh
var rb = interaction.WeCollide.gameObject.GetComponent<Rigidbody>();
if(rb == null) return;
rb.isKinematic = !rb.isKinematic; ```
you guys are just geniuses
THANK you
does anyone know how to get these textmeshes to render in the game view, the "Particle Canvas" that theyre a child of has a higher sorting layer than everything else. I instantiate them in run time which im assuming is affecting it
not enough info, dont see the code question
probably best ask in #π²βui-ux or #π»βunity-talk
anyway to show any particles on UI you need Canvas to be set to Screen - Camera with camera assigned
ah yes you might be right about the channel, its not technically a particle (as in it doesnt use the particle system at all). This is the code that Instantiates them
how would i get 9% of a value???
multiply by 0..09f?
Mathf.Lerp(0f, value, 0.09f);
I have pretty big problem...
This is my script and so.
When I move it works normally.
!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
also dont use screenshots to share code
But I think something is broken because after releasing key it goes back to down view
I have it
you have it but its not configured
So what
you have problem reading?
np lol
blocked list +1
just configure your ide and shut up
bold of you to mock people who are trying to help
Oh no way! This guy gave emoji on my message!!! So scary and tuff
Okay, have fun figuring it out on your own then
Nope he isnt
It's not just one person. No one here will help until you've done the bare minimum to make your tools actually function
He is that one person that just trolls
Actually you are wrong
There were some guys that were helping me with something
stop projecting and just get your IDE configured as you've been told to do multiple times.
says member since "june 6"
but yeah no time for this arse. goodluck ppl
Lol, buddy maybe you do help someone but the only thing I see is you being as cocky as possible
No offense
Only to people who deserve it
are there any mods to mute him?
Lol?
Funny
why dont you figure out the problem by yourself and then make a post on reddit on how the people on unity discord are super rude
I'll try that
that might fix your ego
get your ide configured. it makes it way easier for you to help yourself, and for us to help you
The King Of Kings
InteractUI.SetActive(true);
if i wanna check if this UI is active how can i do it without typing it like this : InteractUI.SetActive(true); isUIActive = true;
I was asking MANY times how do I do that but NAV was only sending !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
This was only response
yeah because we don't need to spam it
you only need the link once
Did you... did you read the bot
Yes I did.
did you click one of the links?
Yup
and did you go through all the steps to get your ide actually configured
Yup and half way it just crashed
Either .activeSelf if you care if this object itself is disabled or not, or .activeInHierarchy if you care about whether it's active by any means, including if its parents are deactivated
cool, ask about that
what step were you on that caused a crash? and what exactly crashed, your ide or unity editor?
just to make sure, this is LMC right?
assuming you mean left mouse click, yes
π¨π
It's the Left (or primary) mouse button
very informative thank you
unless the primary was set to the right button, i guess. i should look into how that actually works
Mouse0 = left
Mouse1 = right
Mouse2 = MiddleButton
it's not mouse2?
ops
ah lol
mouse3 and mouse4 are also back/forward for mice that have those buttons
If you swap it on the OS, it basically just treats the right button as "left click" and vice-versa
So, if you swapped it in your mouse settings, right button would be Mouse0
dumb question again
I want the function to only execute if the left mouse button is hold down, not pressed if that exists
Mouse0 aka M1 aka LMB aka Left click
Mouse1 aka M2 aka RMB aka Right click
Mouse2 aka M3 aka Middle click aka Scroll wheel
Mouse3 aka M4 aka Back
Mouse4 aka M5 aka Forward
Mouse5
Mouse6
WheelUp aka Mouse+ aka M+ aka Scroll up
WheelDown aka Mouse- aka M- aka Scroll down
i love words
GetKey is held
KeyDown is the pressed once thing
This server is better than reddit fr
hah readdit has some funny answers
getkeydown = the frame it's pressed
getkeyup = the frame it's released
getkey = is it currently being pressed?
i don't think there's a "has been held down for some duration" built-in, if that's what you're asking
What isn't these days?
i mean, it's a different format
that's more of a forum, this is a chatroom
chatgpt
Well, that's not really fair. Twitter still exists.
no it doesn't smh my head
someone called me lazy for asking about new mechanics ideas
i mean you'd probably just get ghosted here
did i?
Then don't be lazy . . . π
depends on how well your question is written, i suppose
there is #archived-game-design which you can probably ask such questions
but not if its just "give me idea"
also yeah depends on the space
i'll check it out
r/Unity3D
something like
"Im doing x y but feels rough and maybe new idea for z to compliment x or y "
probably not a great place to ask then
there are dedicated subreddits for game design
just like this server - your question wouldn't fit anywhere other than #archived-game-design or #1180170818983051344
yeah that place is just very wrongly answered questions or people show casing their game as "I quit my job so I made this in x months"
some gems here n there
I said all indie horror games have the same mechanics like pick up the trash, fix the generator, etc,
yaa.. dont forget keys! and doors to unlock
here
don't forget poorly-lit hallways
or ps2 graphics
huh? not really
nahh Jumpscares...jumpscares out the ass..
people think "horror, ok I need jumpscares"
fr
people forget Horror is more of a Mood
silent hill
yeah anything that sets good mood of uneasiness without cheap tricks
think Exorcist (1973)
you telling me to go supernatural then huh
I am doing it
you hang out with friends then go to cemetery then you know what happens
Rather than creating something to "fix" a problem in another game, it's better to just come up with something you want. Be additive, not subtractive.
Rather than "Game minus problems"
poppy playtime rip offs?
I'm pretty sure that's exactly the kind of thing I said to avoid
mathf functions dont care if its 2/3d its just float functions
functions change a bit is physics function, eg Rigidbody vs Rigidbody2D
I figured it thank you
if you're using it for something actually 3d like a Vector3, you can use Vector3.Lerp, fyi
you technically can use v3 for 2D it just omits the z to 0
Rigidbody2D rb ;
rb.position = Vector3.Lerp(pos1, pos2, t); valid
It's just a function that gets you a value some percent of the way between two numbers. You can use it for all kinds of things
That was actually what i was trying to do
mathf.lerp can be used inside new Vector3() right?
new Vector3(Mathf.Lerp(a, b, t), matf.Lerp(a, b, t), you get it)
again its just a float
It's a function that returns a float
it can be used as a float
you can use it anywhere you put floats
because it is one
oh
thanks again
for the 5th time actually
yeah, but you can just do Vector3.Lerp for that if you want to lerp every member
used this
much simpler than the other way
hi guys
this isn't a social space, https://nohello.net
a bool to turn true after a moment? Like this:
Destroy(gameObject, 10f);
but instead of destroying you turn a bool to a value true/false
Use a coroutine
if a stop action on particle system is set to Destroy
it's causing an issue in multiplayer games where it's complaining why am I destroying an object from a client
how to fix this?
Restructure things so the particle system object isn't owned by the other player
it's not, im just telling the server to destroy an enemy then instantiate the deathEffect, which is a particle system
and it's done inside an RPC
public class EnemyController : NetworkBehaviour, IDamageable
{
public GameObject DeathEffect;
public void Damage(float amount)
{
DestroyRpc();
}
[Rpc(SendTo.Server)]
private void DestroyRpc()
{
if (IsServer)
{
Destroy(gameObject);
var instance = Instantiate(DeathEffect, transform.position, Quaternion.identity);
instance.GetComponent<NetworkObject>().Spawn();
}
}
}
Why would you spawn a particle system on the server?
That doesn't make much sense
Does it do something besides just being a visual?
how are other players gonna see it?
You send an RPC to them and they spawn it locally
i think i understand u
but since it's a coop game, meaning the host will be a player's machine
shouldn't all communication be with server?
that's my conclusion based on what I read
Or they do so on their own when they see the enemy die
- Coop has nothing to do with the network topology of using a Host setup
- The fact that one of the players is a host doesn't really change anything here
"host will be a player's machine" is called p2p/peer to peer, nothing to do with the nature of the game
btdb2 is pvp and it's p2p
ok so, if it's just visual
u spawn it on clients
if it's something that moves, like an enemy and needs to be synced across clients, it should be spawned on server
correct?
If it needs syncing it should be a network object
Otherwise, it shouldn't
Basically all UI, visual effects, and cameras should not be network objects
@wintry quarry
Thank you, it worked and i have better understanding rn of how things should be setup
I wanna thank each one that helped me make the draging system come true, and it doesn't have any glitches at all! (definitely the objects doesn't slip from the cursor then magically come to my hand again - or somehow for some reason i go upward and i cant go down because of an invisible platform under me)
what's game dev without glitches right?
what's dev without glitches
You can also use OnDestroy and set the bool to true/false in there
i had rb component with a character controller in my player gameobject
removed rb and it works good
Yeah those are two physics objects but don't mix
yeah then ontriggerenter doesn't work...
thats a problem for tmrrw
gn
It does
character controller is still a physics controller so OnTrigger works fine. The OnCollision doesn't but has its own function
if the collider has a rb, yes. if both doesn't have 1 rb, it doesnt
Trust
I've used CC for many years never did i need a rb to make trigger function work
one is without a rb the other is with a rb
i literally has to sacrifice one mechanic; Draging/picking
You'd have to show the complete set up
or there is something in c# idk about
` public void OnTriggerEnter(Collider other)
{
WeCollide = other;
if (other.gameObject.layer == 8)
{
Name = other.name;
InteractUI.SetActive(true);
isUIActive = true;
}
if (other.gameObject.layer == 9)
{
DragUI.SetActive(true);
rb = other.gameObject.GetComponent<Rigidbody>();
}
}`
Is the CC moving into the ball or is the ball moving into the CC? Was this interaction triggered by .Move or by something's transform getting updated?
imagine the ball an apple, an item you need to collect in order to do something
the item doesn't move no
Cool. Now Is the CC moving into the ball or is the ball moving into the CC? Was this interaction triggered by .Move or by something's transform getting updated?
So, the CC is moving into it by .Move?
Specifically, changing transform.position or other transform manipulations will not call OnTrigger methods
I am moving the character/player with WASD to the item to collect it
WASD does not move anything
WASD is input
other than that I honestly don't know what y r saying
In the code
What function do you use
there is a capsule that gets moved by WASD input, I move the capsule in First person to the item (which is fixed) then collect it using trigger from a capsule collider
Pressing a key does not make an object move.
Somewhere in code, you are reading that input then moving the object because of it. How are you doing that movement
Are you actually using unitys character controller , wdym a capsule
honestly, the player movement script is a Ctrl + c Ctrl + v
So look at it, and check
so I don't even know
screenshot components on your player
`moveDirection = horizontalMove * currentSpeed;
moveDirection.y = verticalVelocity;
characterController.Move(moveDirection * Time.deltaTime);`
Okay, there we go
So it's using .Move properly
ig
Can you show the inspectors of both the player and the thing with the trigger on it
so what do that have to do with anything...
It's not a trigger
there will be alot of items
Okay?
Do you understand the purpose of isTrigger bool?
i will not be writing all those scripts for all of them
or am i missing something?
Are you sure because now I'm doubting how this thing was even working with RB
And what does that have to do with anything
You must been using OnCollisionEnter or sum
It's not a trigger.
Why are you expecting it to run OnTriggerEnter
but it isnt
this is a trigger. this object would be detected by OnTriggerEnter
yeah
OH
I NEED TO ADD RB TO THIS INSTEAD OF PLAYER
No
There should be no rigidbodies involved
Waste of resources
Make the item you wanna pickup have an actual trigger collider
Put the pickup script where the player character controller is
If your item to pickup needs a collider to be collided with then also add a regular collider
the sight is a child not a parent tho
that's it?
That does not change my assertion
There should be no rigidbodies
OnTriggerEnter runs on both objects when a character controller intersects with a trigger collider
i got 2 seperate scripts that do the pick up thingy, i put the one with OnTrigger or both?
CharacterController will call OnTriggerEnter on itself and the trigger object when it touches a trigger collider
Whatever you want to happen, you would put it on one of those objects
wait what exactly is on Sight, the object ?
@rich adder
rb for dragable objects
not for interactables
Idk what rb for draggable objects mean
its a multi task script so...
rb of that thing I am draging
for physics
matter of fact if i sent you my full script u won't understand none
I usually use casts so you'd have to explain what is even going on... If you are using sight to detect stuff for whatever reason then yes you'd need a rb as I don't think CC counts children collider for OnTrigg
You'd have to lock rotation and position on the RB though
It's messy but it works ig.. look into casts or even overlaps for the future tho
I didn't know about casting rays, and no glitches just happen or the script doesn't work at all, it was just a project to experiment new things so Its not that important
Thanks @rich adder @polar acorn @naive pawn
I have this error coming up and I don't know how to fix it, I copy pasted it from a tutorial as it said. I am also missing the "interaction_Info_UI" component in my inspector (The images provided is of the tutorial's inspector and my code). I am still a newbie so I am unsure what I have stuffed up for this error to happen, cheers!
I believe yesterday when you asked this I asked what InteracableObject was and you never replied
sorry I had gone to sleep, I've just now logged on for the day
I don't really know I just copy pasted the code like the tutorial said
the image on the left is only saying there is no InteractableObject.cs
perhaps theres more to the tutorial or u missed something?
So what component are you trying to get
the interaction UI bit in the image i provided
It's not there on my game, only the script thing
looks like it hasn't compiled yet
You cannot assign anything in the inspector until you fix your compile errors
Which brings us back to the question: what is InteractableObject?
so you missed a step
then u missed something.. or he wrote the scripts out of order
So check the tutorial
You cannot solve the error until you actually have an answer for "What component are you trying to get"
You cannot get a component that doesn't exist
You're trying to get one named InteractableObject but it appears to not exist
So if that doesn't exist, what do you want
i want it to exist
Then you'll need to create it
The same way you've created any file
or it is in there
can you send link
get ur counter ready
haha work your magic
#survivalgame #tutorial #unity
In this tutorial series, we will create a 3D survival game with Unity & C# as the scripting language.
We will start with basic FPS movement, inventory building, and crafting systems.
Learn how to pick up items and more.
Little by little, we are going to add different features that are common to survival open-world...
its after we make the text
around 7:30 or something
gottem
what does that mean
it means you missed it but its there
thats where he's creating the script...
im not up to there in the tutorial yet
ok thank you so much i appreciate it!
Or in a previous part. This is part 3 and they're all an hour long
facts
yes i've watched them all
I'll have to save The Counterβ’οΈ for later I'm on mobile data and I'm not loading 3 hours of YouTube on it to scrub through

They did for a while but then they got rid of it
wouldnt the mouseX and mouseY values be inaccurate?
Hence the sad pepe
input class just voodoo to most ppl
DeltaTime for mouse movement makes the sad frog sad
anyway.. good luck kickflip peanut butter π
mouse input already returns the "delta" movement since last frame so already frame independent
I don't get it
when they finally deprecate the old system for good we'll never have this problem, i'll learn it by then.. lol
Oh, wait, the username delta
ya, im lame it wasnt even funny
I just read that as a tent
ohh snap!
thats even better lol
has anyone been using that AI tooling from unity.. or is that just for art stuff?
the one in Unity 6.2 ?
ya, built in in the toolbars
ah, nvm i bet thats editor only stuff
hence being in the editor π€¦ββοΈ
oh thats gonna be a paid sub anywaay no ?
I hope that crap is just a seperate package we can remove, I'd like not to have ai infested app
π― it'll be paywalled
quick question, can I put methods in my SOs?
beginner here need assistance fixing panels on my 2d game
!ask π
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #πβfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #854851968446365696
pay particular attention to the last few points
ofc haha
!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.
Hello folks, I'm starting to learn unity dev by myself, and I'm trying to create a simple game (flappy bird).
I had a little question about the looping background, what's the best practice for that kind of things ? I found several solutions, some using transform, some using quads... But might as well start learning the good way to do it right ?
wdym " some using transform, some using quads." ? those are different things.
transform stores the position, rotation and scale.. quad is just a shape
I'm just starting, I don't know what is a quad really. i'm just wondering what is the best practice in this case
Simple way is to initially spawn a row of quads that contain a texture, and gradually spawn mode after that when the last quad's position reaches a certain point while scrolling.
Same the other way around, destroy quads that got to the end
A performance improvement would be moving quads that reached the end back to the start and reuse these.
(btw Flappy bird originally doesn't even have a moving background, so it's hard to say what you want to actually achieve here)
the real best practice is whatever you find easier to do faster
what's it mean when it says CharacterController is a type but used as a variable?
or like a variable
i'm following a tutorial because appearently there's nothing for the newest update, and despite turning on both new and old formats, i'm getting errors in places others aren't
it's made learning this program a bit difficult since nothing works right
even here, it's saying characterController does'nt contain the term move, i'm not sure if this is something i have to set up myself, but it seems fine in the tutorial
which, most of the tutorials have been exactly like this
what type is characterController?
can we see your whole script?
you can use something like https://paste.myst.rs to
right ok
so the issue is that you're using your class name there instead of a variable
okay so up at the top you've got public class
that's the class name - that's the blueprint essentially. Think of it like "human" or "apple", it's the type of thing
this line here is getting your CharacterController from the object
it's putting it into a new variable of type CharacterController called CharacterController
however, that new variable only exists inside the curly braces
it doesn't exist where you're trying to move it
that was the recommended fix by unity itself
i figured i'd go along with it until someone answered
so you want to have CharacterController CharacterController; outside the start method, next to all your public variables
then CharacterController = GetComponent<CharacterController>(); in Start
then CharacterController.Move( in Update
Unity doesn't have recomended fixes. visual studio can offer suggestions based on built in assessment of your code or sometimes just made up bullshit from ai related predictions
consider it, don't assume it
You also shouldn't name the variable the exact same as the Type. Usually you would use camelCase here so
characterController
yeah I wasn't going to comment on that because it's an extra thing π get it working is the priority lmao
And now I also see the name of their class 
this is the fix!
do this first then we can help you understand the rest π
so where all the floats are?
You should 1000% drop what youre doing and go do some c# basics then. You shouldn't be struggling with both c# syntax and trying to learn a game engine
yeah that's right
There are pins in the channel for learning c#
isn't C# and unity kind of different though?
eh, getting things working is typically fun, and it's usually easier to learn when you've written something and are getting help about that thing
you understand more
the C# fundamentals will help
C# is c#. Unity uses c#
unity has a layer on top of it, but it's all still C#!
figured maybe it'd be better to learn from just tossing myself into the fire, i get so bored trying to learn just fundementals
alright, CharacterController CharacterController; is in the start area
yeah that's a reasonable approach tbh
why is it so different from the tutorial?
every tutorial i've found something was completely different
Its fun to build a rocket ship too. Doesn't mean people should skip the fundamentals because something more advanced is fun
I don't know what tutorial you're following - but typically there is no one way to do things
it's a first person camera
i think building the rocket ship is fun if it's a small rocket ship and you slowly build upon the learned ideas from that and recreate your own fundementals.
i've always struggled with just reading to gather fundamental knowledge, it's so boring i can't stand it, makes the whole process such a slog.
Character movement is entirely unique to your game. There will almost never be a tutorial that entirely fits what you need in your game
cant dive into a language you don't understand
sometimes you do have to get through the boring stuff
A small rocket ship is a rocket ship. If you cant do the basics, its blowing up either way.
y'all are not getting me, but that's ok
i said the tutorials weren't working, because i've had to type things a lot differently, they changed a lot of the terms, so some of it doesn't work the same way, which makes learning the tutorials hard
Ive gotten the point from the first few hundred people in here that were in the same spot you were.
You cannot brute force trying to understand something way more advanced than what you know.

i'm an artist, i draw, i skipped doing fundementals to just draw what i wanted, even if it looked god awful. 6 years later my art is pretty damn decent and i had fun, there are multiple ways to approach a project, you don't need to tackle fundementals EVERY time.
We are giving you realistic advice. If you wish to struggle through c# and unity at the same time, we have no power over that. Just know you will burn out much quicker when you struggle at literally every step. We've seen this many times by now
you dont have to every time, you do have to for this
then why's the advice i've received from others in the field to just 'go for it'
π€·ββοΈ who are these others. They could've never touched unity for all I know
you're so entirely wrong on that
you misunderstand what i mean by explicit rules
alright, i'm done with this conversation, i don't wanna hear another word on fundementals.
public class characherController : MonoBehaviour
this bit is telling Unity that you're making something that can be attached to a gameobject (that's what : MonoBehaviour does) , and its name is characherController. Typically when we're naming classes, you want to start it with a capital letter - so in this canse it would be CharacterController - however, CharacterController is used by Unity so it might be better to call it something like PlayerController. You'll also have to rename the file
the section with the public floats (and now your CharacterController) is a list of all of the "properties" of your class. An apple has a size and a weight, for example - those would be floats. It also has a core, which isn't a simple number. Your code can "see" these anywhere else in the class
void Start ()
this is a Unity specific thing, it runs when the object is first loaded. You're using this to get the character controller that is attached to the same object - GetComponent<CharacterController>()
void Update()
another unity specific thing, this is called every frame.
This is just a very brief overview, but it's the sort of thing a C# fundamentals course would teach you!
your drawing cannot fail to compile
you're not getting it, that's still ok, you'll understand at some point maybe, because while art can't 'compile', it can look like utter dogshit, and no one will like it, and you'll have to keep going and repeating it until you manage to figure out how to fix it.
yes but thats my point
looking shit is not the same as not looking at all
your code does not work
thats not bad thats nothing
if there is an error, you can look it up, use a tutorial, ask for help
we are suggesting you use a tutorial
At this point they've made it clear they just dont want to listen to the advice. Better to just let them learn the hard way.
the most relevant tutorial is the fundementals
now, i don't want to hear another word on it, because this has been a pretty damn forceful
thank you.
that's fine, but it is worth mentioning servers like this and others will end up telling you the same advice if your not interested in learning the fundementals and still want help
Yea you really are going to get a lot of the same talks from many different people. Especially if youre clearly struggling with c# and trying to implement anything more complex
dawg i said i was done hearing about it
i will go learn the fundementals when i want to, i don't have to do it right away, let me struggle, i like to struggle.
Then dont read our messages if you dont want. Neither of us pinged you on these last replies π€·ββοΈ
if you dont know spanish and wanna write a book in spanish anyone willing to help is going to tell you to learn spanish
do i need to go grab an admin or something? i've told you both repeatably to stop.
(you can choose whats on your screen)
when it's flooding the conversation when someone IS genuinely trying to help, then it's a bit annoying, yes i can ignore it, but when i have two people telling me to go do something i already know i should go do but don't want to do yet, it get's pretty repetitive. and honestly burns me out far more than any 'struggling'
(the other person also told you to learn the fundementals)
thank you for describing a few of these things to me! i think i'm gonna mess around and see what works for a bit longer then.
yes but they also told me what a certain thing meant and why it's important to choose a distinct name
all y'all have done was anything anyone else can do.
i'm far more appreciative of dom because he actually told me something that related to my question instead of saying "oh bro just go learn fundamentals"
If you were so adamant about dropping the topic, then maybe stop replying about it also. Just incase you didnt see, one of the first things I also said was advice about naming convention there
#π»βcode-beginner message
yes, thank for that, unfortuntely it was overshadowed by that blank profile and i got caught up.