#💻┃code-beginner
1 messages · Page 456 of 1
ah
Raycast detect colliders
mm nope it didn't print it out even with cylinder on the layer of pipe
but your cylinder is above it's parent
look at the Y position
why is the y position of the child relevant?
because that is what gets hit first
it shouldn't matter anyway as i've changed the layer mask to the child anyway
Is the collider on the pipe good? That center looks suspicious
show inspector of Pipe object
it's alright
ok, so nothing will hit that
why not?
it has no collider
It should hit the child though
it shouldnt?
Select Window- analysis - physics debugger . Go to the queries tab and enable everything , run playmode and check for raycast
yes, it will hit the child and REPORT the child if it meets the criteria, i.e. the LayerMask
yeah the child has the layer mask
i don't see anything
Your Collider Center looks very odd indeed
You need to enable gizmos. Check the scene view. Select the player
perhaps but even when the capsule goes through the cylinder nothing is logged regardless
but it looks like the Cylinder collider is no where near the cylinder renderer
#💻┃code-beginner message thought so too but from this screenshot seems ok
yeah still nothing
is this what you mean by selecting the player?
Yes I see the red ray. Wait nvm that’s the move tool
Click player and press F
Also why is he below pipe
i haven't gotten around to stopping him from doing that for now i just want to log when he touches pipe i'll get around to that later
there is no way that collider is in the correct position, screenshot looking down on the cylinder with the cylinder selected
Why is it now a ball lol
its a capsule
Oh… ur underneath looking up..
Select the player click F in playmode .
You have to see where that raycast is first and foremost
sorry, but i hide the player to get this screenshot, what's the shortcut to unhide things
I just realized, those center points are very small (missed the e at the end). Reset them to 0
Idk the shortcut just use the ui buttons
what is a center point?
the center values of the collider
ah, i reset those to 0, but still
it's not logging anything
Are your colliders triggers
no
This player doesn’t even have the script…
the parent has the script
Where is the parent at? Select it and press F
Your player is far away from it
It’s obvious by the position relative to parent
Because you used transform.position (zero clue why my phone is not making that a code bracket) and the script is on the parent, it will try to use the parents position. Not the childs
Nvm I guess it was making that a bracket
Indeed. script is basically super far away from player
Never put logic and components on child / graphics when possible
Always root
neat thanks y'all sorry for bothering you, changing the location to 0,0,0 for the parent fixed it
You mean child ?
nope parent
Also why is your child so far away from parent
the parent was way off
they're on the same position
How?
Ok so did you reset the capsule position
The child moves in respect the parent
(PlayerVisual)
Yeah, so the child object
That’s the one that need 0,0,0, since it’s restive to parent
Putting parent at 0,0,0, doesn’t do anything but reset it to world 0 pos
yeah
If you moves the capsule you moved the child
i know
Yeah so the child needs to be 0,0,0 not the parent
Ok now it’s correct
Good 
👍
Okay I've scripted an enemy with movement, attacks, health etc. This includes public methods to deal damage to it and so on. This was all done in an EnemyController class in a single file.
It started to feel like it got too big, so I moved the HP-related things to a separate class/file. This would mean that I would need another public method for the EnemyController, to which I send a signal to die.
I'm starting to feel like it might just grows bigger for not very much benefit. Any guru that can guide me in the right direction? I intend for the same script to be used for multiple kinds of enemies, and control behaviour with public variables set in the [SerializeField]
A code file like yours and like everyone's will always get bigger the more you add to it. You can make it look cleaner by reducing/eliminating nesting, unused code, etc.
You can also rewrite some code if you want to try and make it smaller. Trust me you should see some of my scripts 😅
If you really want to make it super clean you can remove brackets from if statements and push code up next to it (as long as it isn't more that 1 line)
If(something)
// do something
Thanks but what I'm asking is about separating it to different classes which interacts with each other via public methods, and if it's worth it?
You know, best practise?
Hey, I got a sprite that disappears if I zoom in on the scene view, any idea why?
Could it be that you're moving in the scene view, and simply move past it?
No I zoom in on it and it disappears
Check clipping plane
Wait I dont think unity has that, you can always press F to focuse on the object and it will adjust the clipping plane
Do your functions all rely on each other to work?
Also this is 100% personal preference by the way
In my opinion you can do it by putting everything in 1 script but I think you should separate health in it's own script then applying that to everything you want it for, you could do the same for damage if you would like.
Damage is already moved to it's weapon
Yeah I think I'll separate it all to different classes
I instantiate a new weapon for the enemy when it loots a weapon, so I kind of needed that separate
Hello, I am a Unity beginner and I tried makin an Idle Game I thought of myself but I struggle with it a lot. I have a concrete idea of what and how I want to make it with rooms for improvment. Is there anyone intrested in making Idle games here? I have troubles with coding and putting it together, I used to work as a project manager so I am good at organizing, making ideas and creating content. The games are different then the classic Clicker games and I would love to talk about them with anyone who is interested in colabing on this. I just wanna be able to play them since I havent find any idle games like the ones I thought of.
Does it have something to do with my animation that changes the camera's rotation that I can't move my camera on the Y axis ? The controller normally allows the camera to move so
!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
thanks I will post it there
new guy here and I am a bit lost 😅
Best advice I can give you !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I did and I also followed tutorials but I get overwhelmed easily so it was too much for me and I am looking for help because of it
did you write a GDD ?
Hey.
int[] ints = new int[] { 1, 2 };
ints -= 1; //error
How do I subtract arrays like this?
for loop
we would need to see code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public CharacterController controller;
public float speed = 10f;
public float gravity = -9.81f;
public float jumpHeight = 5f;
public Transform groundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
Vector3 velocity;
bool isGrounded;
void Update()
{
isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);
Debug.Log(isGrounded);
if (isGrounded && velocity.y < 0)
{
velocity.y = -2f;
}
float x = Input.GetAxis("Horizontal");
Vector3 move = transform.forward * x * speed;
if(Input.GetButtonDown("Jump") && isGrounded)
{
velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
}
velocity.y += gravity * Time.deltaTime;
controller.Move((velocity + move) * Time.deltaTime);
}
}
is the ground layermask on the slope?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.InputSystem;
public class GrabItems : MonoBehaviour
{
bool isHolding = false;
public GameObject objectHolding;
public Vector3 posToHoldAnObject = new Vector3(0, 0, 10);
Camera cam;
void Awake()
{
cam = GetComponent<Camera>();
}
void FixedUpdate()
{
if (Mouse.current.leftButton.wasPressedThisFrame) {
Debug.Log("clciked");
var ray = new Ray (cam.transform.position, cam.transform.forward);
if (Physics.Raycast(ray, out var hit)) {
var Object = hit.collider.transform;
Debug.Log(ray);
Debug.Log(Object);
isHolding = !isHolding;
Debug.Log(isHolding);
objectHolding = hit.collider.gameObject;
}
if (isHolding) {
objectHolding.transform.position = transform.parent.gameObject.transform.position + posToHoldAnObject;
}
}
}
}
Mouse.current.leftButton.wasPressedThisFrame sucks in fixed update what else should I use? it detects like 20% of the time because it's a fixed update
ints is a collection that holds multiple integer values. You cannot subtract from a collection; you need to access each element from the collection to get the integer value . . .
it detects like 20% to somewhere 30% of the time
Private Void Update()
i would recommend looking at unity documentation for this
as well
I know but I want to do it in a fixed update
yes
also i have never seen that type of input before
change ground distance
when the character go up here, it can't jump
can you select the slope and take a picture of the inspector
it's system input or how it's called
here
i understand its an input, why couldnt you use if(input.getkeydown(keycode.iforgetwhatthemouseiscalled))
idk people say system input is more fancy
what?
idk tbh
its just more easily configurable but for small projects its not worthy tbh
change grounddistance while on slope in game
oh ok I'm doing small projects
unless youre planning to make them for different platforms or you want configurable projects but thats unlikely in small projects
I have this weird problem where the script can access things within the child of the hit gameobject but cant access things within the actual gameobject. https://pastebin.com/P8V1ARZw - line 6 works perfectly while 10 and 11 don't
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 old input system is way faster
loosing my time over I don't know what I'm doing
what do you mean lines 10 and 11 dont work?
do they log an error to console?
I get a nullreference exception
obviously the components are not on the hit.transform object
oh lol
but they are on the gameobject
if they are on the parent use the getparentcomponent
which is the confusing part
how do you konw? you have debugged nothing to check
if if you are hitting the parent and the components are in one of the children use getchildcomponent
wasnt it something like GetComponentInChildren?
how do i do that?
change grounddistance from Private to Public in your code
I can see in the inspector that the script is attached to the gameobject Im interacting with
ah alr
then go in game and adjust
you are just guessing that is the hit object
theres nothing else with the same tag
then debug.log the hit object and prove it
I just did, it points to the player(clone) gameobject which has the needed components
code does not lie, if it says NRE you have a NRE
Facts . . .
so I increase it and it works, but when I jump to the next platform it goes false so I can't jump
hey, quick question about Unity UI Toolkit
basically i have a GUI composed of createable and deleteable menus (VisualElements), composed by a Visual Tree (which i show in the image below) and a manipulator
would it be worth it to make an object pool just for these VisualElements?
is it expensive to load a visual tree?
check the same steps i told you before, does that platform have the layermask, also lower the distance a bit. you seem to be floating when you hit the ground
make the distance good enough to go up the slope
nothing more
hey! im not an expert on subclasses,
if i have a class, Item
and a subclass WeaponItem
and a list of items, how would i sort by which items are weaponitems?
you could sort on the Type of the item
so I tried increasing the distance but this happened
wdym? sorry
dont just increase distance always, i said make the distance good enough to go up the slope
so lower it to just enough to go up the slope
presuming you have a
List<Item>
you can make a custom comparer which uses GetType() as the comparing factor
have you tried to !learn how to use unity?
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
i would suggest that you do, im not trying to start any hostility its just you are not reading what im saying correctly
Quick question, Vector3.up, forward, etc refer to the game objects position relative to itself rather to the world?
World
Ah
transform would be local
Thank you
Is there a builtin method to check if a state exist in an animator?
Like, I wanna check if "death" exists before tring to play it
gameObject.GetComponent<Animator>().Play("death");
check the name of the animation clip
oh wait you wanted to check if it exists at all .
dont use animator component
use animator
Yeah, I was actually looking at browsing through the animations and use IsName to check if it occured, but thought that there has to be an easier way?
Hmm I think you lost me
you can loop animator to check which clips are there
Oooh, thanks
Animation component afaik was deprecated no ?
whats stateID though ?
I was looking at this, but it only accepted int as input
You can just use this, check if array contains it
https://docs.unity3d.com/ScriptReference/RuntimeAnimatorController-animationClips.html
probabley a String2Hash of the state name
Hit Lerp on the beginning scripting pathway and it's purpose is to calculate the point between A and B using percentages?
This one didn't have a video so there isn't really a demonstration
lerp is giving the result between two values by ratio. but yea you can think of it as A to B by ratio amount 0-1 ( or 0-100%) if you look at it like percentages
has nothing to do with pathways or anything specific though
in this case it helps "smooth" out movement or other values, over time if you modify the ratio, but its not the only use case ofc
So go and read the docs
Should I create a Dropdata component in which I specify variables such as Drop Chance or the Weapon that is necessary to use in order to obtain this drop or should I just add it to ItemData(even though not all Items are going to be obtained by a certain drop)
Awesome, thanks a lot
so are we to assume what these all mean without context?
Imagine a tree that drops different types of Items which have an Item SO which defines their data, should I include the dropRate and the weapon necessary to collect the item (as an enum) in that SO or is it better to create a separate component to include that information?
hi
ohh..I would make it a seperate component tbh but thats just me
i like to have specific components handle their specific tasks
for drops I just store the SO in array then pick whatever from there based on loot table for example
So ItemData and DropData could be separate components right?
so like list[i].GetType == typestuf
?
I would do it so yes. If it makes sense for your system, use that
DropData would be where you stored your drops SO yes?
something like that, did you go and read the docs on Comparers in C# ?
also, when I Instantiate the drop, the GameObject I instantiate contains an "Overworld Item" component which handles the collection of it. However, does it have to contain the Drop Component as well?
no, that may help
could u link?
why would the item dropped care about the drop component at all ?
thats "in the past"
item was dropped already, it doesnt need to know about the dropper or any of that
wot? No Google?
Start here https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.sort?view=net-8.0 and drill down
So the dropper should have a DropComponent List and drop the chosen Item by Instantiating a GameObject with the OverWorld Component?
depends on your set up, generally you spawn the prefab you want witht he components already on it yes
@brazen escarp ha nice try scammer
bot has outsmarted you
In my architecture, the Dropper has a List of "OverworldItems" that can be instantiated, then a process is carried out to choose what drop to pick and finally it instantiates
okay yeah that sounds fine
however, the problem here is that the dropRate, for example, should be included in the OverworldItems to choose what drop to pick but, you are right, that doesn´t make any sense because why should a component like that store that information?
You could have a dropRate chance or something on it , it might be acceptable on ItemData too
or you can store it in a dictionary as well tbh (less clutter but more processing each time to access the dictionary just to read a value)
yes, but what about if I don´t want all of my items to be obtainable by drop?
yes then you should have a component for that, if it has that Drop component then read its data such as dropchance etc
even item data can have it tbh. You can just check if its Null for example , that can mean the item is not Droppable / obtainable that way
You want the whole folder?
but when the object intantiates it will still have that Component, but it has no use once it is put onto the world
Okay, that may be a good way to solve it
thanks for your attention
yeah then go with second option for sure
if(itemData.dropData == null) // item is not a droppable
does anyone here have experience with coding a tank controller? I need it to react with uneven and slanted surfaces without using a whole separate system for treads joints. I was wondering if anyone knows if that is achievable just using the normals of the slanted surfaces
wdym by "react with uneven and slanted surfaces "
void FixedUpdate()
{
if (isHolding) {
objectHolding.transform.position = transform.parent.gameObject.transform.position + posToHoldAnObject;
}
}
}
how do I make a player hold an object? objectholding is object that is being holded and the script is attached to MainCamera. This one doesn't do what I want when I rotate my camera it holds an object in the wrong direction
I don't want to parent an object that I hold to maincamera cus it will noclip then
currently I'm preparing to add rigidbody3d
setting position manually is still gonna be imprecise
I will change it later to rigidbody3d forces or velocity but rn keeping it like that to make at least something work
if you are using rigidbody then use the velocity or movePosition
then simply do heldpos-rigidbody.position
apply direction accordingly to vel
its kind of hard to see but the terrain here is very rough and jagged. If i use a box collider then it quickly gets out of hand and starts bouncing when moving into slanted edges. This could be fixed by using treads with joints, but coding a system like that takes far too long and is overkill imo.
wouldnt you just use Raycast to get the normal ?
then use Project dir or something
of course i know how to get the normal, but im just asking if the object not rapidly jerking between each slanted surface is achievable
I just want it to work how I expect it to work then I'll change it to rigidbody, should be same thing
why not use wheel colliders like most tank controllers?
I told you how to do it
how can I hold in the right direction?
idk what "jerking" means in this context so idk the cause
where?
is it even possible to apply the wheel collider to tank treads? They're less wheels and more like smooth edge rectangles
subtract the positions to get a direction and apply it to the rigidbody velocity
freeze the rotation if you dont want it to spin
I suggest you go and look at a decent tank tread tutorial
tank treads are wheels, they are about 8 wheels with suspension
the tread is there for grip
oh you're right actually
damn
so yes
but I'm doing right now without a rigidbody,
how should I substract it?
subtracting two points gives you a direction with a magnitude
regardless of rigidbody
objectHolding.transform.position = transform.parent.gameObject.transform.position + posToHoldAnObject; what would I do with it (posToHoldAnObject is just vector3(0, 0, 2))
you use wheel colliders and a skinned mesh renderer, it works real well
first id make the hold position a seperate gameobject so its easy toget the consistent position according to direction
objectHolding.transform.MoveTowards( objectHolding.position, objectHolder.position, speed *time.deltaTime)
Is there a way to deactive the gameobject and when it turns on again it gets reassigned again? or do i have to do the manipulation there manually too?
OnEnable
reassigned to what exactly tho
@rich adder may I ask a question? i did this already
CS0120 An object reference is required for the non-static field, method, or property
i kinda understand dot notations now but when I try it it gives me this error
(reference question to the reply)
because you're probably trying to use the Class directly and not the instance of the class
i have a class who holds reference to the player, when the player gets deactivated it turns null but then when it gets turned on again it stays null
ohhh so I need to make an instance within the class first then call it out
why does it set to null in the first place
well no.. the Instance is the one on the gameobject
reference that
MB shouldn't be created inside other classes
im not sure, im doing gameobject.SetActive(false);
and it turns null
huh..afaik making a gameobject inactive should not break references
is the player a new player or something
Are you using .Find as well ?
its the same one
no, its being assigned on the inspector
then something else must be setting it to null. SetActive will not do that
check for any GetComponent too
if i understood it right then I need to make an instance for the public transform target?
you need to reference the Turret script that is on the GameObject
no. you are probably trying to do Turret.Target. you need to use an instance of the Turret class to access it's Target property
on that note, the instance in the case of unity MB is when they are on a gameobject
ohhh this one
thats what I said earlier when you are trying to Use the class and not the instance
okay okayyy
the class is just a blueprint to an object
if its not monobehaviour derived, then its created with new()
monobehaviours instances are created by unity though when you run the game
so to recap, the script (component) thats on a gameobject is the Instance
so when you see Null Reference bla bla "Not set to instance of an object"
it doesnt know which instance you want because its not assigned
so for example with the one that I did. I would make another instance for Target? since just declaring it would be using the turret class directly?
if you want to access the target on this turrent you need to reference the specific turrent instance you want the target from, plain and simple
the script is already on a gameobject
that is for example the actual instance
click it it leads you to the gameobject
if Target.cs is a class
you could declare it like
Target myTarget;
then u just assign which instance u want that reference to refer to
myTarget = GetComponent<Target>(); or drag and drop a gameobject that has a Target script attached to it into the slot
when you do [SerializeField] Turret turret
u drag it into the slot
and the code just does
turret.target
for a public Target myTarget for example
not reference the actual Apple class.. just an instance of it that exists on the Apple gameObject
it doesn't have a game object rn to target since I use a function to detect enemies
ahh i see
so that's why I cant do this
ya, but u can still access target from Turret
Turret yourTurret; <-- if this is assigned to a turret
then it'll have a Target
but currently its private.. so u couldn't access it outside hte class anyway
oh u have a public one too
my bad im just waking up 😅
https://hatebin.com/ndlmsilvso here is my code if you wanna see
👍 thnks im lookin for the original quesiton too
this one?
well theres this.. if ur trying to access target before ur assigning it the target = hits part it'll be null
yea i understand that
could wrap ur code thats using it in a conditional
if(target != null) -> run the code
else ignore it until its not
the code isnt loading btw
kinda get it now
ohh i see now
yea its here.. like navarone was saying.. thast the actual class Turret
yeaaa
you need to access an instance to it intsead
so i'll make like target new target?
[SerializedField] Turret myTurret;
void Start(){
target = myTurret.target;
}
this target = myTurret's target
ohh so doing it directly would mess up the code that's why when I call Turret.Target in the other game object, it wont work
you cant new() a monobehaviour i dont think
only difference access the Target uppercase
wdym "doing it directly"
unless Target was static (ie it belong to the class itself) you need an instance
Turret (uppercase ) is just a class, a blueprint
well the script is asking for Turrets target.. Turret may never exist.. or it may exist 1000 times.. it doesn't know which Turret to get target from..
(until its put on a gameobject aned assigned target isn't really a value its just a type)
"This will be this type of variable"
I need this blueprint to do X and Y.
Which instance(spawned object) of this blueprint do you want?
^ yea think of it like that
its like when you use gameObject.transform <-- this will get the transform from the GameObject your script is on.
BUT if u say GameObject.transform its gonna error out just like ur doing now
b/c GameObject is a type.. it isn't an actual instance of a gameobject.. which gameObject is
same thing w/ ur Turret.. and theTurretReference
to add to the confusion, if the field/method/prop is Static then it does indeed belong to the class itself
such as static methods like GameObject.Find etc.
damm you static :shakefist
they are very handy when used properly for sure
ohhh since the turret is a class i just cant call it. so i need to make an instance of it
yes
yes!! EXACTLY
that's why we made new variables
YES!! exactly
but in this case Unity makes the instance
Vector3 is also a struct(similiar to class) but because its not a component but a regular c# object we use new()
its a recipe.. you dont eat the paper recipe..
you cook the meal using the recipe.. and eat that instead
haha good anaolgy , now I'm hungry 😋
eureka moment
steve about to drop some truth bombs
you've never tasted my wifes cooking, the paper one tastes better
i understand now
with enough time and no food, you will eat that paper
savage af.. i wont tell her 🤫
Steve surpised you didn't build a personal Rosey to cook
at least ur wife cooks
she damn well doesn't,, at least if I can help it
my wife just knows how to use my card to order out
I just cant.. lmfao! too early to laugh this hard
id kick mine out cause I'm the one who makes the fire food lol
is and operator & or &&?
can't order out here, we live in the middle of nowhere, nowhere to order from
&& is a if conditional. not sure what & is.. i forget
Both. Use the second
&& will shortcircuit if the first is false, meaning it won't need to do both conditions for no reason. & will always check both
ok
& is a bitty bit thing
the & confusing cause of its usage in bit operations
yea bits i was right! 🙂
if (conditionA && conditionB)
{
// This block will not execute because conditionA is false,
// so conditionB is never evaluated.
}```
```cs
if (conditionA & conditionB)
{
// This block will not execute because the overall result is false,
// but both conditionA and conditionB are evaluated.
}```
with this it doesn't have an error anymore. But my antivirus still won't output the target of the turret
just null
then target hasnt been assigned to anything in the turret when Start() goes off
i just put that line in Start() as an example
not sure it makes sense in ur context
ohhh okay okay
wait i think i get it now
wait let me try it
if Turret was null you'd get an error when trying to access it
but if target was null.. no error b/c ur just assigning a value to null.. nothing technically wrong w/ that
so its not a legit error
so it just reference the turret during the first frame
that's why it didnt work
so anything that needs update should be in update
makes sense
only if its local
well, yes and no
did you only make a local variable?
if you assign a field it should persist through the whole class not just within 1 method
show ur newest versions of ur scripts (after u get done tinkering)
you dont need to assign it every frame
yeaaa the myTurret right?
its usually ^ yea not advised to do things every frame unless u need to..
no that would be a field, its not local
now if ur Turrets target will be changing thruout the game..
its correct but not sure why you moved it from start
then i guess it makes sense sorta
yea it needs to
once you get a reference type, its the same object
that's the idea
it wasn't assigned via the Turret @ start..
his Turret script needs time to assign one i think
yeaa
and if its ever-changing.. then u need to update it
yeaaa
Events would be how iwould do that..
oh right target is assigned Update in other script
but not gonna recommend events to them just yet
yes event would be good
or ur Turret script could (Loop thru all ur antiviruslvl1 scripts) and assign the target once it has it
btw you can just write this as
public Transform Target => target;
no need to have a public setter on this if you have a backing field setting it
(that way its only being assigned that once for every target change)
ohhh, since i have a field now it doesn't need a setter anymore]
tbh you might as well call FindTarget from the property rather than doimg it in Update
correct
okayyyy~
yeah you could technically just put it when you get
that is, after all, the whole point of properties, to execute extra code
"field with benefits" lol
absolutely
I like the idea of how y'all tutoring me like a kid hehe, I learn more with actual people teaching me, quite interactive ig?
really thankful for yall advices and teachings
You've still got a long way to go but at least you're trying to learn which is more than can be said for most of the people that come here
i mean. It's interesting to have projects like this and quite having fun learning too
It's gotta be fun, I've been doing this for a long, long time and I still find it fun
https://hatebin.com/cckizqswbq
just another example.. you could for example have a script that knows about all the things needing a target..
then for-loop thru them and set the target any time the Master (ur turret) target has changed
buts its all relative.. and how you need things to work.. but i feel like ur catching on regardless 👍
hi, im following a very basic tutorial on c# and i have to write the very basic command Console.Windowheight, but when i do i get this error: This call site is reachable on all platforms. 'Console.WindowHeight.set' is only supported on: 'windows'.
does anyone know a solution?
ohh so any gameobject that needs a target would automatically have this turret as their reference
without needing to assign them one by one
well in my example my Master which is ur Turret (it has the main Target) knows about all the other scripts that need a target
Hello, I was just wondering how can I find good sounds for my game , every time I start polishing my game I don't know how to find sounds
Console class isnt used in unity
so when it gets assigned it runs a loop thru all the other scripts calling
I have no idea what you mean or why you are asking in a Unity server
oh rip
SetTarget()
welp onto another server
!cs
Join the C# Discord server, a programming server aimed at coders discussing everything related to C# (CSharp) and .NET. https://discord.com/invite/csharp
it just passing in the transform.. and then it assigns its own target
thxx
Hello, I was just wondering how can I find good sounds for my game , every time I start polishing my game I don't know how to find sounds
not code related
check pins in #🔊┃audio
many diferent placed.. but word of the wise.. (learn to audio-edit) urself.. using Audacity, Ripper, etc..
sounds are always almost what u need..but never exact
Gotta love the way that any serious game dev puts a great ammount of effort into sounds for their games and then the first thing most game players do is turn the audio off
(╯°□°)╯︵ ┻━┻
sounds really do add all the environment to a game
nuance
absolutely, very, very important for atmosphere
a boss fight aint a boss fight without the music that makes you contemplate life
watch a film with nothing but subtitles and see how much you lose
Was wondering if anyone could help with the jittering I see when using velocity tracking? I'm sure it's a setting I'm using but I don't know which
(Brand new to u ity and programming in general)
For real. For my first experience, that jump from soundless basketball game to "Lobby Music", "Level Music", "Ball Thump Thump", "Win Applaud", "Lose Womp Womp", etc. was sooooooo satisfying 😋
oh i imbed failed, one sec
Does anyone know what this error entails: GameObject (named 'Euporia') references runtime script in scene file. Fixing! UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
The script on the Euporia gameobject is "missing" apprently
As for this, would these warnings be the reason I can't move my camera? https://i.gyazo.com/2cb1776b68a499846da5050002636c62.png
that's the only thing in the console
No
read them.. you know ur camera system more than we do.. (are any of these values that say are unused have anything to deal w/ ur camera)
just w/ an educated guess imma say that Building.cs doesn't have anything to do w/ the camera
anyone know whats going on with the velocity tracking? im sure theres a super simple fix i am just not seeing it....
I want my object to track my hand accurately and collide wth objects
(i want my hands to collide with objects too but that seems harder...)
No it doesn't. https://hastebin.com/share/vozawofaza.java
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Here's the camera controller
I've been trying to figure this out for days and I just can't seem to figure it out
Inputs are also set up in Unity
I did follow a youtube tutorial about it and his seemed to work but not sure what I did differently. I don't think I did anything differently, I've watched the tutorial multiple times to confirm we wrote the same thing
how do i call variable across scripts can yall give me an example?
just like that 
my puny brain cant handle it can i get more simplier one i barely understand english
public class Cat : MonoBehaviour
{
public void Pet() { /*purrrrr*/ }
}
public class Human : MonoBehaviour
{
[SerializeField] private Cat cat;
void Awake()
{
cat.Pet();
}
}```
Awak
opp
The forefathers of the Ewok? 🤔
oh god lets forget that even existed
It's growing on me
public class test : MonoBehaviour
{
bool Isgrounded;
CharacterController CC;
float verticalspeed;
float gravity = 9.81f;
float height = 5;
]
public class GetTestValue : MonoBehaviour
{
int test verticalspeed;
public void Start()
{
?????
}
}
i dont get it until this far
Your camera just doesn't move at all, for any input? Or is it some specific input/movement?
You need a REFERENCE
aka saying "I want something from This script"
how do i call it?
you don't call anything
thats what im doing for the pass 15 minutes
It doesn't move at all
but cant i not just get one of the variable?
can someone explain how the viewDir is calculated? i dont rly understand why he uses player.position - ...
see how I want "Cat" to use something inside there from Human? a variable ( member field) , method, its all the same usage
also they need to be public
Good and cute example 😭
To get a direction vector that points at something, you subtract the destination position with the start position.
public class test : MonoBehaviour
{
public class GetSpeed()
{
float verticalspeed;
}
bool Isgrounded;
CharacterController CC;
float verticalspeed;
float gravity = 9.81f;
float height = 5;
]
public class GetTestValue : MonoBehaviour
{
int test verticalspeed;
public void Start()
{
verticalspeed.GetSpeed();
}
}
Like this?
subtracting two positions will give you direction with magnitude
honestly im more confused with unity api than c#
The reference stuff is just C#
so is this correct?
wtf
:/
is it important to know what these calculations do and why u use them to get good at coding?
actualy no the more i look it and the worse it gets @iron steeple
this is gberish
public class GetSpeed()
{
float verticalspeed;
}
compile error
Well, yeah. If you want to know the direction to something it would be important to know how.
did you read the docs I linked, it explained how useful are vectors n such calculations
they are particularly important in a game not much to do with being a good coder tbh
now im confused now
Vectors are positions in a graph. In 2d it is exactly like middle school graphs. Subtracting them will give you the difference
its more important to know what a thing does than how it does
oohh this explains it well, thanks! now i understand
once u get more advanced its more important to know why it does rather than how it does
you're confused because you need to take basic c# course. Id start with the ones in this channel pin
I believe you should learn some more C# which will take your time a little (depends)
so if u dont know how its calculated and why its impossible to know how to write the code by urself?
huh?
vector math has nothing to do with writing code by yourself
why tho i feel confident on my c# im not used to unity api project
its specific to game development not coding, things that move in a 2d/3d space etc.
Your issue is a base c# issue. Nothing to do with unity
Probably unrelated, but you have a bunch of weird namespace imports that I don't think you're using
using System.Runtime.CompilerServices;
using Unity.VisualScripting;
using UnityEditor.Experimental.GraphView;
using Unity.VisualScripting.Dependencies.Sqlite;
That said, what is the Controls type?
nah man i dont even know how unity works
Ok. But your issue had literally nothing to do with unity
alot of good developers still dont know how unity works..
It was just not understanding c# scopes and method returns
forget the unity part, you need c# fundamentals
what you wrote is literally syntax error
it wouldnt even compile
Dont get overwhelmed. The Unity is like built on top of C# which you can access the codes if you wanted to. Just knowing C#, you could understand how their systems work easily.
knowing the Unity api is just icing on the cake..
Good way to put it
once you learn how read 1 api you can pretty much use many other libraries besides unity
okay how is that fix my problem with the one currently im facing its like your learning test blindly that has extra questions
a lot of the times i go diggin in Unity's specific classes and methods i feel underwhelmed lol..
"yup, thats what i expected to see" But always expecting it to be some magic sorcery i cant understand lol
nah bro i feel more refined on c# than basics coding of unity
i dont want to start a fight but
But... again... nothing about your issue had anything to do with unity at alll
my guy, you wrote something completely nonsense unrelated to unity
If you wrote the same thing OUTSIDE of unity, it would also be wrong
well i did follow your example
not at all
unity works off of standard c#.. it just has alot of helper functions along the way.. (thats the way i think of it)..
when i have a coding issue.. its b/c of broken c# code.. not broken unity code
ontop of the other ones.. this would be another compile error
if you knew c# as you claim you'd know why this is wrong
since public void pet() can be deriavie from making method so i made a variable inside of that so the cat.Pet() would transfer the variable over script
This is not valid C# and never was in any api
Agreeee When i need their built-in things, they somehow be internal or private to their own API only 
you wrote public **class ** "MethodName" instead of the return type of method
and yet you told me its correct?
You wrote class GetSpeed()
That is broken c#
yeah well I some parts looked correct at a glance, I quickly corrected myself though
didnt you also wrote it like this?
a while ago alot of the stuff was leaked (accessible) but since then they've put a stop to it.. (alot of their stuff is now just hidden forever) lol
No they didn't
where did I put an unrelated constructor in my Cat class..
cant even call that a constructor actually cause it has class infront if it.. the whole line is nonsense lol
There's nothing in there that says public class FunctionName()
oh i see how wrong actually
Does it now make sense why we are saying it is a pure c# issue not related to unity now? We are not trying to be harsh.
A basic c# referesher would just be very helpful
public class GetSpeed() ---> public Void GetSpeed man yall didnt tell me what i did do wrong :/
i think ur taking offense to a suggestion thats just meant to be helpful, more than anything
I have almost a decade experience with c# and I just took another refresher
We did multiple times
thats one of the issues yes..
even if you put void it still logically makes no sense..
weird tho i just did a c# refresher like 4 days ago
its just a local variable now sitting there..
well You need a better course then cause it aint work
Seems like you need another one if you managed to squeeze at least 3 obvious compile errors in that short piece of code
The type before a method identifier is the type of the value which it returns. void indicates that the method returns no value. So
void GetSpeed()
is a method which doesn't return anything... which seems strange for something named GetSpeed(), no?
thanks man bro this is much more helpful then telling me i have at least 3 errors jeez
int speed;
This is a declaration. You are creating an int at value 0. It only exists in that method and then you throw it away
GetSpeed literally does nothing at all
Does that make sense?
a complier would also told me what and where does it located 😦
tbh if you did a quick crashcourse on c# the problems would become obvious to you right away without us needing to explain it.
Something even more helpful would be you going through a C# course because you seem to have issues with absolute fundamentals
weird i thought this is Beginner Coding not like treat me as a Advanced
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class las : MonoBehaviour
{
AudioSource audio66;
// Start is called before the first frame update
void Start()
{
audio66 = GetComponent<AudioSource>();
StartCoroutine(las_dzwiek_start());
Debug.Log("1");
}
// Update is called once per frame
void Update()
{
}
private IEnumerator las_dzwiek_start()
{
yield return new WaitForSeconds(3f);
Debug.Log("2");
yield return new WaitForSeconds(1f);
Destroy(gameObject);
}
}
why delug.log("2"); doest work?
#💻┃code-beginner message
Does this make sense?
This is by no means advanced code, it's below beginner
We are trying to help, but you just keep arguing that it is not a c# issue when it is
Please just let us help you
no way I did that, I give you a literal example..wdym
yet yall treat me that i can solve 3 unexplain errors
Does the objecr get destroyed from anywhere else?
i sent you the page, you said it was hard, I made a code example as you asked. what more do you want
Please stop ignoring what I said and arguing
no
Can you show the console uncropped? Including the icons on top right
i give example back and yall told me its half correct but yall like saying i should learn c# again while not explain what i did wrong in the line nor pointing it out
Ok, stop
If you just want to complain and argue, then leave and calm down
is the script "las" on a gameobject with an audiosource. if not, nothing runs
why tho i just ask what i did wrong on the code yall didnt tell me 😭
What you did wrong has been explaoned multiple times, very clearly
You're expected to put in some minimal level of effort to educate yourself as well
You keep ignoring it just to argue
just STOP ARGUING lol
I am done though.
Not gonna explain it again
but yall didnt point it out which one??????
what?
nvm ignore what I said, you posted the pic of it right as I sent my message
i ask one thing to tell me where i did wrong and point it out? how am i supposed to correct my code if i dont know where is the error code line originated
fair
I answered multiple times. I even linked to it and said stop ignoring it. You continued ignoring it.
I am blocking you. You need to stop
Hi All , I have a trouble with this :
public class A
public class AA : A
public class BAbstract < TA > where TA : A , new( )
public class B : BAbstract < A >
public class BB : BAbstract < AA >
public class C < TB > where BAbstract< A >
new C < B > works new C < BB > not 😦
I don't understand why. Someone can explain me ? 🙏
well tbh your call
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class las : MonoBehaviour
{
AudioSource audio66;
// Start is called before the first frame update
void Start()
{
audio66 = GetComponent<AudioSource>();
StartCoroutine(las_dzwiek_start());
Debug.Log("1");
}
// Update is called once per frame
void Update()
{
}
private IEnumerator las_dzwiek_start()
{
yield return new WaitForSeconds(3f);
Debug.Log("2");
yield return new WaitForSeconds(1f);
Destroy(gameObject);
}
}
why delug.log("2"); doest work?
what if you put another debug above the first wait, to check if the method is being run at all prior to the wait
If you look at the channel description, it clearly says that it's for asking about things related to beginner coding concepts in Unity. Your issues are related to basic C# concepts. Most if not all issues were pointed out (as a remainder to gather every issue up - line 3, 5, 12 and 16) and you were advised to take a C# course. That's about it.
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
fair
C<BB> does not work because BB does not match the BAbstract<A> constraint.
im no expert but you can probably use a common interface here ? or baseclass?
ty for reply 🙏 But AA extends A it's not 'the same thing' ?
can you teach me step by step?
so you can use baseclass ?
It would be much, much better to just place a file in appdata or the registry that blocks the program from launching again rather than delete the files, that can easily be confused with malware
(not to mention if you mess up while coding it there's a non-zero chance of you deleting a chunk of your unity project)
it work
why would someone even do this..
streamerbait
just delete the savefile / progress. Just seems kinda stupid if you ask me..
using System.Collections.Generic;
using UnityEngine;
public class las : MonoBehaviour
{
AudioSource audio66;
// Start is called before the first frame update
void Start()
{
audio66 = GetComponent<AudioSource>();
StartCoroutine(las_dzwiek_start());
Debug.Log("1");
}
// Update is called once per frame
void Update()
{
}
private IEnumerator las_dzwiek_start()
{
Debug.Log("Eapple is my love");
yield return new WaitForSeconds(3f);
Debug.Log("2");
yield return new WaitForSeconds(1f);
Destroy(gameObject);
}
}
very inconvenient to the player..
It's idiotic, but definitely a thing
There was a russian roulette game that popularized the concept awhile ago
crazy..ima take it to the ultimate level and just make it so you can only install it once per pc. I had this concept before unity changed their per-install to uniques
these devlogs are brain rot.. no wonder some think making a game is just "lulz i paste from stackoverflow until it works"
"Here's how I added a two hour ten minute unskippable cutscene so players cant refund"
its printing or not?
i will yes but ( for this moment the only thing i do with if i exclude the type hinting and auto complete ) , i create a new object by that
i will try to understand the covariance 🙏
Oh I was just reading that link cause yeah i had to refreshen up but yeah if it worked it worked xD
Hey, how can I recreate the effect of the snippet of Mario when transitioning from 2D to 3D in Super Paper Mario, in Unity?
ex. https://youtu.be/nny1-SWK8Pk?t=5851
so its not printing coroutine ?
is timescale set to 1?
or are you destroying / disabling the object
no
i dont know what is that
oh wait ur just trying to destroy it?
just use the parameter inside the Destroy, it has a float for timer
yea
use a side scrolling orthographic camera normally, include functionality for switching it to a third person perspective camera
Your main issue is going to be it makes level design very """interesting"""
what kind of parameter is this?
No like, it's hard to explain but what I mean is Mario's animation when the room rotation is happening
just rotate the sprite
but without destroy the script doesn't work either
if you want to get fancy, use a rendertexture of whatever is behind the character at the time and just arrange them under a parent transform then rotate the parent transform such that you get that effect
wdym it doesn't ?
Did you put it on start ?
if it printed the log in Start its clear is working
like i said, only thing that can coroutine is stopped without running stopCoroutine, TimeScale is not above 0, object gets disabled at some point, or destroyed
idk if Im missing something else
If the 2 never logs, then either:
- The object is destroyed or deactivated before 3 seconds are up
- You are modifying
Time.timeScalesomewhere
I didn't do any of it
How do I know that? the code thats running is saying otherwise
start printing some logs maybe.
OnDisable() => Debug.Log("Disabled");
Update() { Debug.Log("Timescale: "+Time.timeScale); }
etc
Hello brothers. I am new in programming. I need help.
using System.Collections.Generic;
using UnityEngine;
public class las : MonoBehaviour
{
AudioSource audio66;
// Start is called before the first frame update
void Start()
{
audio66 = GetComponent<AudioSource>();
StartCoroutine(las_dzwiek_start());
Debug.Log("1");
}
// Update is called once per frame
void Update()
{
Debug.Log("Timescale: " + Time.timeScale);
}
private IEnumerator las_dzwiek_start()
{
Debug.Log("Eapple is my love");
yield return new WaitForSeconds(3f);
Debug.Log("2");
yield return new WaitForSeconds(10f);
audio66.Stop();
}
void OnDisable()
{
Debug.Log("Disabled");
}
}
well there you go..
oh nvm that disabled is from stopping play..
Brothers, Was anyone see my mesegasse? I need help!!!!!!!!!!!
no one can help without stating a problem
No one's going to ask you to ask your question. Just ask it
saying " I have a problem" is redundant in a help channel tbh
actually no
Ok first how i can learn unity?
nice lol was going to send the line same, but forgot to hit send
Got you! I'm supporting you morally!
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
I'd recommend starting with the Unity Essentials and Junior Programmer Pathways on Unity Learn ☝️
public class A
public class AA : A
public class BAbstract < TA > where TA : A , new( )
public class B : BAbstract < A >
public class BB : BAbstract < AA >
public class C < TB > where BAbstract< A >
change to :
public class C < TB , TA > where BAbstract< TA > where TA : A
new C < B > , new C < BB > all works with this
TY for your try helping me 🙂
Thanks
hehe no problem!
wdym by that?
yes that Disabled got called when you stopped the game thats why its last
When a scene gets closed / game stops the order is Disabled . Then OnDestroy runs
if object was disabled it would stop printing Update as well
BAbstract can be marked abstract
This is the case in the real code but thanks for noting it. it's an oversight on discord 🙏
I'm still pretty new so this is what I was following: https://youtu.be/kaU11fqe5yE?si=wcv5JT_soMJis-7L
In this video tutorial series I will make a massively multiplayer online real-time strategy (MMORTS) game like clash of clans. I will be using a TCP networking solution that I have already published and also use MySQL database to store players data.
Discord:
https://discord.gg/FWwDgKjcKQ
GitHub Links:
https://github.com/developers-hub-org/unit...
Ah alright - so Controls is a class generated from an input asset 👍
Have you sprinkled some Debug.Log()s around to try and narrow down the problem? E.g.
private void MoveStarted()
{
Debug.Log("MoveStarted called.");
if (UI_Main.instance.isActive)
{
_moving = true;
Debug.Log("Started moving...");
}
}
im using this function each frame to detect if my player character is grounded but it is returning true a few frames (sometimes 1 or 2 frames but other times it takes a little longer) after jumping and I can't find why. the player is a capsule object with scale 1.
I'm using this to set the vertical speed to 0 if the player is on the ground
you're saying its returning true while you you're in jump ?
yes
since you're not using layers its more than likely its hitting itself (player collider)
ahhh that makes sense
btw you can shorten this whole thing to just be return Physics.Raycast etc..
the else statement is redundant
more than likely, it's still within the 1.01 range of the ground and so is considered grounded
the jumpspeed is set to 100 and I am clearly off the ground
but how far per frame?
1 unit but also its starting from the pivot, it might be in the middle so take another /.5 off
im like 2 player heights off the ground when it happens most of the time
so I dont think that is the problem
is there a way I can disable it checking its own collider?
yea put Player in its own Layer then put a serialized Layermask variable in this script then plug that in Raycast function
make sure to then only select Default layer or whatever other things you want to be considered ground
hahah i will have to look up a tutorial for layers first in that case
yeah layers are good way to filter out objects https://docs.unity3d.com/Manual/Layers.html
think of them like Tags but better and applied across different usecases
then you use the https://docs.unity3d.com/ScriptReference/LayerMask.html type
alright thanks :D
although its still weird the ray doesnt detect the player every frame in that case
you can send the full script using a paste site
https://gdl.space n such
how did you verify this delay ?
you said there is a slight delay when it goes into grounded
debug.log
btw * Time.deltaTime never do this on Mouse Inputs
mouse inputs are already framerate independent
and then just looking at the console after i stopped the thingy mid jump
they are still in the code btw
use something like this
private void OnGUI()
{
GUI.Label(new Rect(0, 20, 100, 75), grounded.ToString());
}```
you should be able to see on top left corner the realtime value
alright let me try
wait how do i use this?
I cant put it in the update but also not outside cuz there is no grounded variable there yet
nvm i got it somehow but it doesnt turn on grounded permanently
its just 1 frame
and then it lets the player drop to the actual ground
i forgot to say that earlier my bad
put it in the class, not inside update lol
you should probably not be using Translate to move a character. Why are you not using the built in components like Rigidbody or Character Controller?
not saying that is the issue but just curious why moving transforms
I want to make a counter strike surf clone for which I need some more control over physics and stuff so I thought it would be better to write my own stuff. that said I have no idea what the possibilities are in unity/C# so excuse me if my choices are questionable xD
the numbers are the vertical speed (deltatime not applied yet) and the hehehehheh is my code putting it to 0 because it is grounded
I did run debug in Unity and fixed the one problem it had. It didn't come up with anything about camera control
I honestly have no idea how to do Debug.Log() but yuour example kinda shows me, I'll run through it
also ive just turned off the collider to check and this seems to be true
Hello guys am about to run wild pls can someone teach me or show me a simple way to shoot in unity without using ray cast method am tired of dropping bombs as bullet pls urgent
how can I check if an object has a rigidbody in it?
TryGetComponent
try printing the Hit.collider.name then
what?
if objectHolding.GetComponent<Rigidbody>(); ?
TryGetComponent
ok
there are no other colliders than the player collider
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
so I'm sure its that
well i still see from the code you sent there is no layermask being used so..
also it wouldnt hurt for you to print the hit.collider.name would it to confirm what its grounded on?
so there's if (TryGetComponent<HingeJoint>(out HingeJoint hinge)) on unity what does out do? can I remove it?
its grounded on the one other object i have in the scene
which is a terrain
out in this case gives the value returned if operation is correct
that's what I'm saying
Did you read it
Am here to learn
It says what it does
so for now I can just turn the player collider off and when I need it again when i start working on slopes I will make sure to set up layers and all
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/out
The out keyword is especially useful when a method needs to return more than one value since more than one out parameter can be used e.g.
thanks for the help though
why would you do that instead of just using the layers and layermask to filter the raycast..
because that is a lot of work i dont need to be doing yet
so it just assigns object hingejoint to hinge
it returns the found HingeJoint in this case
if the if statement is true (the component was found)
yep
do note this only looks for it on the same object you tell it, it doesnt look on all the objects too (child or parent)
yeah pretty simple
wait till you readup on ref and have a two way value
Pls I have done three days now looking for one solution pls can someone teach me how to shoot without using ray cast method
spawn a bullet prefab
and add a rigidbody
but be carefull this method is not the best option in every case
Show me pls
show what? You're the one who's supposed to do it lol
Do what
start making bullets
if you want here is a the part that "shoot" in my fps:
private void Fire()
{
MagAmo -= 1;
MagAmoText.text = $"{MagAmo}";
Vector3 shootDirection = ShootPoint.up;
// Ajouter une dispersion aléatoire
shootDirection.x += Random.Range(-dispersionAngle, dispersionAngle) * Mathf.Deg2Rad;
shootDirection.y += Random.Range(-dispersionAngle, dispersionAngle) * Mathf.Deg2Rad;
shootDirection.Normalize();
Quaternion initialRotation = Quaternion.Euler(0, 0, -90);
GameObject AmoInstance = Instantiate(AmoPrefab, ShootPoint.position, ShootPoint.rotation * initialRotation);
Rigidbody AmoRigidbody = AmoInstance.GetComponent<Rigidbody>();
if (AmoRigidbody != null)
{
AmoRigidbody.AddForce((shootDirection)*ShootForce, ForceMode.Impulse);
}
}
I have watch many tutorials and they codes never works with mine
well maybe it isn't the code?
fun fact you can spawn the AmoInstance already as Rigidbody, as long as you change AmoPrefab type to Rigidbody
skips unecessary GetComponent and null check
Sorry to say but this code is for advance users
start from the beginnning !learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
follow the pathways
I need something my brain can peocess
yeah you have to start from the beginning
oh ok interesting! I'll look into it!
that code is not really advanced at all though
Instantiation of a projectile is covered in the first couple of units of the Junior Programmer Pathway
Let me check it out
How many years have you done learning unity
I never stop learning!
i only started 2020
1.5 years till first job, now about 6 years and I still feel like a beginner 😄
i literally feel like I know nothing lol
You got the knowledge of programming in school right
nope
self teaching mostly , lots of times spent on google.
its good to take courses such as CompScience to just get a bit more RAW knowledge how everything works , things like big O notation etc
with all the help you've given me and everyone else on this server, I can assure you that you know a lot more than you think you do. 👍
yeah but compared to the veterans here its like 2% haha getting there slowly
I have less than one year to start working in gaming studio so am not going to fall back
if you want to start you need to start simple
I only started 6 month ago
you're jumping right away into wanting to make bullets guns and stuff you will be overwhelmed
dont jump in to the deep end, keep it shallow until you can learn to swim
at the same time, it's really hard to become a "veteran" without having studied in the field for a long time and without having had extensive professional experience.
making a box move on your own without tutorials or googling , just the docs maybe, has a different feel
its simple but if you do it all on your own, you get that good dopamine rushh
that so true
But does that mean that I have to have full knowledge of programming c#
No
I dont think anyone here has full knowledge of c#
there is soo much , and it changes over time
You will know what you need to know to do what you want
Thanks for the advice bro
Open eight gate of death I must learn everything I want to
That is my ninja way
code is like a basket full of tools, its up to you how you use that
I just had a small question, do the bones work like games-objects, if I want the character's arms to rise and fall following the rotation of the arms in the "FPS" view, can I just apply the rotation to the arm bones or will it not work because of the character's animations?
Hey guys!
I need some help with coding. I have another script that has a public function named TakeDamage and I referenced it in this new script, but it wont reference it. I'm having some trouble.
Basically what I'm trying to do is make it so when the damage happens, it'll play a random sound.
put IK and use the spine bone to tilt up and down
try regen project file
Look at the error, its telling you why the first call to TakeDamage doesnt work
TakeDamage is a method that returns nothing.
Why are you using it in an if statement and without ()?
but also yeah you're using the class instead of instance
Also you are using the class name instead of the variable yeah
reassure me, it's not the only solution ?! 🫠
i thought it was the only logical reason 🤷♂️
Huh?
I mean you can probably just rotate the bone transform now as is, IK just helps with moving everything together so it make sense. Unity has Animation Rigging package, IK is quite easy
None of your code makes sense currently. You should step back and learn some of the basics of C#
I have, I'm still a beginner at this
You need to learn more because you haven't got a grasp on the basics of objects, types, variables, and functions
It will be hard to do anything without that
I recommend https://dotnet.microsoft.com/en-us/learn/csharp
okay, I'll see if I can't do a mix between putting an IK on the spine and rotating the arms, because with all the equipment I've put on the player, if I bend his spine too much, it'll break everything.
how do i reference the grip button being pressed on the right/left hand controller with xr interaction toolkit?
wish I knew, I dont have vr 😢
maybe #🥽┃virtual-reality will know
alright
do you want to just rotate arms or chest too, cause you need to compromise or fix whatever issue you got
you can also limit the amount of IK based on angle too, ie less weight on IK component when you're hitting "extreme" bend angles
I reworked it all into the target script
actually I just checked and it doesn't deform/break my character too much, but I don't really see how the spine has to bend to have a realistic rendering, because the rendering is really goofy 😂
no one bends their chest like that lmao
I know 😂
maybe it's just the upper back and the neck that has to rotate ?!
yes the upper back / shoulder area
upper back bends at slight amount, neck at slightly larger amount, head at even larger amount (just look up in real life and see how you bend)
yeah it works now
ok 👍 I'll try like this
I mean its just a bandaid fix you still need to go over the c# material, you had some pretty obvious syntax error along with some fundamentals lack about references
i guess so
yeah ok I see it work way better moving only those bone !
much better
I dont mind because my character got that juicy rumpp 
i have to fix my hand placement on weapon though lol IK is a pain to deal with sometimes
oops we're in code channel. Back to topic..
I haven't even tried in unity yet and you're already telling me that, how am I supposed to be motivated to do it 😰
well no its easy to setup and all that, but making things look good. That isnt to do with Unity IK just me not being an animator/modeler
anyway lets keep the channel relevant to code, if you have IK questions best ask them in #🏃┃animation
what force would be needed to be added to an object to make the net force of gravity and the addiction force being added 0 in 2d
ok 👍
would it not be ? Vector2 gravityForce = new Vector2(0, -Physics2D.gravity.y * objectMass); + additional force ig
i will try that
the object is flying up
i tried it with just 9.81 and the same thing happened
well if the forces cancel each other out it would be as if you are in zero gravity, which would mean you retain whatever velocity you have forever
i might be able to work around the problem
I need walking codes pls and running pls
google them. This isn't like a "handout full code" server
okay
is your goal to just make everyone else make your game for you? 🤔
// Variables
speed = baseWalkSpeed
runMultiplier = 2.0
// Input check
if IsKeyPressed(RunKey)
speed = baseWalkSpeed * runMultiplier
else
speed = baseWalkSpeed
// Movement
MoveCharacter(direction * speed * deltaTime)
That'll be $10
copies and paste
Its not working!
nah, theres no way.. that isnt even c#
that's probably too complicated for them. they need something simpler like this:
private void Update()
{
if(walk)
Walk();
if(run)
Run();
}
thats fix w/e that is
Oh ok
Oh I'm supposed to paste it somewhere ? 
but anyway.. you never even told us details. like is it a Character Controller.. is it a rigidbody.. is it first person, is it third person? 2d.. or 3d..
these are things you know.. so use those details and find some tutorials related to exactly what u asked
but !learn first for ur own sanity
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
if you want out of the box, use the Unity premade characters in starter assets 
make something move first -> then turn it into a character
||those aren't very good|| ❤️ ya unity
good base to work on but yeah they aren't like parkour or anything
if they're out of the box, production ready they bad..
if they're starter kits.. like a Barebones PC build kit.. to work off of.. then they are sufficient and probably pretty good start
the third person one tbh is more handy cause it already setups the jump animations n stuff for you
i can't remember if they've changed them to use the new input system or they're still polling w/ input class
ohh ohh true true.. i forgot bout that detail
nah ur thinking of Standard Assets maybe?
the Starter Assets always came with the new Input System
yeah these always came with new input sytem
standard assets are broken for me, have been a while..
Checked it cus i was curious, pretty understandable too idk what means two way value tho maybe because english isn't my main language
i have an old archive of them on my system for the cool things like particles and whatnot
meaning you can both Read and Assign the value from outside the method
out is only read result from method within that specific class method
void UpdateValue(ref int x)
{
x += 60;
}
int number = 9;
UpdateValue(ref number);
Debug.Log(number); // Output: 69```
vs
```cs
void InitializeValue(out int x)
{
x = 69;
}
int number;
InitializeValue(out number);
Debug.Log(number); // Output: 69```
ahh, the more you know! 🌈 ⭐
void ModifyHealth(ref int health, int amount)
{ health += amount; }
int playerHealth = 100;
ModifyHealth(ref playerHealth, -20);``` a good example of **ref**
- output `playerHealth = 80`
no need to return the value *and* reassign it. with ref we can directly modify the og variable
**edit: dang, navarone beat me too it.. **