#🖼️┃2d-tools
1 messages · Page 40 of 1
if it doesn't work keep trying
i just deleted it
coz that suc-
oh well
at least try and make another game
keep trying
there are so many things to learn in unity
im gonna use the same assets
still confused why it would even compile though
float x = Input.GetAxis("Horizontal"); //Checks for forward/backwards movement on a keyboard or controller.
float z = Input.GetAxis("Vertical"); //Checks for movements on the sides.
Vector3 move = transform.right * x + transform.forward * z; //Defines what MOVE is
"YOUR PLAYER GAME OBJECT".Move(move * speed * Time.deltaTime);
``` This code might work
shooters are my most fun type of game dev
you might wanna use vector 2 tho
unity is full of ways to move things around :d
this is mine, but you could also use transform.Translate()
you can use
Vector2 Movement;
Rigebody2D rb;
Movement.x = Input(blah blah blah)
Movement.y = Input.(same thing)
rb.Moveposition
uhhh
wait limme try and remember
its been long since I did a top down shooter
ah yes rb.Moveposition( Movment * speed) * Time.deltatime
probably got it wrong
ok take your time
@inner vine also, try to follow the lords tutorial... Brackeys 2d series https://www.youtube.com/watch?v=on9nwbZngyw&list=PLPV2KyIb3jR6TFcFuzI2bB7TMNIIBpKMQ&ab_channel=Brackeys
Want to make a 2D game but don't know where to start? This video should help point you in the right direction!
● Free Assets List: https://bit.ly/2tv7aBU
♥ Support Brackeys on Patreon: http://patreon.com/brackeys/
····················································································
♥ Subscribe: http://bit.ly/1kMekJV
● Websit...
he covers everything
this one is out dated
like still have somethings but pretty outdatted
I recommend using the unity tutorial playlist
Watch this video in context on Unity Learn:
https://learn.unity.com/tutorial/scripts-as-behaviour-components
What are Scripts in Unity? Learn about the behaviour component that is a Unity script, and how to Create and Attach them to objects.
I think this one will lead to the entire playlist
yeah unity covers almost all the basic c sharp programming things so I recommend that tutorial since its the most reliable
ok
nvm ill just find a dif one that is not that outdated
the unity tutorials explain them very clearly
the brackeys tutorial cover the intermediate things about unity like shooting and ui
if you want to learn unity like a master I recommend an underrated youtuber called code monkey
his tutorials are 20 minutes long but the code is simple enough to modify but not understand
can you send me to a tutorial of him with a 2d platformer?
there is not really a 2d platformer
I haven't seen a better tutorial of it
but he did make an excellent top down shooter
brackey mainly focus on the other aspects of unity like homing missles
so I guess you will have to make the 2d code yourself
yes
OMG LOL
HE DIDNT EVEN MAKE ART OR CODE IN THAT TUTORIAL ALL HE DID WAS THIS
its funny to me
hmmm never seen that one before
It is called Setting up, and looks to be a first video in a series.
Can someone tell me why is there 2 red ans blue
line
i tested this and there is errors. why wont it move?
Configure your Visual Studio properly so you don't have to ask discord: https://docs.microsoft.com/en-us/visualstudio/gamedev/unity/get-started/getting-started-with-visual-studio-tools-for-unity#configure-unity-to-use-visual-studio
whats the best way to implement a main menu
There is no "best" way, but a common way is to make it as a separate scene that loads before your main game scenes
ive tried to make a seperate scene but it just gets layered on top of the other scene.
wait
why didnt it move?
i might have put the seperate scene inside of the current scene o-o
maybe you didnt give the script to the rigibody?
¯_(ツ)_/¯
its rb.velocity = movement
hm
yeah its rb.velocity = movemen-
this is what made me quit unity on my first day tbh
it was so dumb
idk how to save tho oof
it was just a button
that we both need to press
hm
o u forgot to save? lmao
i also do dumb stuff
o
...
what errors are there
....
oh I see
o-O
can you tell im annoyed rn?
ok you placed the colon
beside the movement logic
and not a semi colon
: != ;
it was one mistake lol
the compiler thinks its the brackets wrong
hm
I need to learn my grammer
can you screen shot and put a circle at whats wrong?
ok
it makes it easier for me
I am too lazy to fire up paint to this this shit lmao
needs to be ; not :, like that
yes
i fixed it and guess what
more errors?
ok uhhh click on the error
it would usually bring you to the place they think is wrong
hmm I think you should do it like:
void Update()
{
\\code
}
oh I see now
your spacing is wrong af
i dont see the spacing issue where?
also no semi colon on line 18
try to tab the funcitiom
YEAH IT WAS. when was it removed lmao
I mean in coding
is it for a 2d game
¯_(ツ)_/¯
Oh i see
im a begginer btw
m
but I need help with that
because I can't run it
and I don't think this works at all
like this?
collision only happens when you touch something
I know that
idk how tho
so you can't really run it
put your line at the line of the thing you want to tab
and press
the button tab
on your keyboard
this? lol
no the code is just there for example
is there anyway to fix this? I have a platform that moves up and down, but when it moves down my character bounces
and yes you did it right
just press tab
on the function
void
plus it keeps your code clean and tidy
can anyone help me with that ^
wait so are you trying to say you want the character to stick with the platform and not move at all?
uhhh haven't encountered something like this
still move but not bounce
I was trying to find things searching but only found something about when colliding to set the player as a child to the platform
and that was what I was asking help for up there
but I can't run the code through update
I was thinking abou tthe same thing but I think you can
use rb.moveposition
you can use
OnColliderStay2D
same thing
but you can run the code multiple times
I wished I found out about that sooner
so how do I do it? I'm a bit confused on where to put things I just got into learning this stuff
its the same thing as OnColliderEnter2D
but it hits multiple times
or you can
OnColliderEnter2D(stuff)
{
(parent player with platform
}
so it's basically its own Update function
OnColliderExit2D(stuff)
{
(unparent)
}
ye
I think you should use the OnColliderExit way
when it sets the player as a child it still bounces
I saw something saying to attack the player to the platform
would that be making it a child
nvm
how do I make it unparent after exiting collision
hello! I am athran and I want to learn how to move the camera's w/ the player
any tips on how to make a trailer? (not really sure what channel this question goes into)
SetParent(null)
Ok
or you can transform.parent = null
Hey there! Can i have a tutorial for pathfinding when i have dynamic spawning objects with colliders in 2d?
hey guys
I am trying to have a panel with clamp and snap properties to basically pull up the top of the panel to snap at 3 different positions(bottom, mid to show partial information, top to show complete panel). Should I be using the default scripts for both? Any suggestions?
Also, how do I change TMPro button's Text color from black (interactable on) to grey(interactable off)? For normal text component its just using GetComponent<Text>().Color but for TMPro I get lost when I get to GetComponent<TextMeshProUGUI>().text ...
Is it vertex gradient or Color32?
Thank you
cs1002
what the frick do i do then
also why is unity acting like the files are corrupted
heres my code
how do i fix?
also that code's not gonna work
Vector3 vel = rb.velocity;
vel.y = movement;
rb.velocity = vel;
srry srry wasnt paying attention to the other stuffs
put it to this?
can you show what the places i should replace?
jsut replace your line with my code
line 19
you need to use all of the code I gave
that's from some other code you added.
And you've simply misspelled Vector2
should i replace vector 3 with vector 2?
ok
The error messages have line numbers on them. Look at the line to see where the error is
oh frick
oh wait
my bad
yeah use Vector2 instead of Vector3
I didn't notice this is 2D physics
Vector2 vel = rb.velocity;
vel.y = movement;
rb.velocity = vel;```
oh
movement is a Vector2 now
then you just do rb.velocity = movement;
instead of all 3 of those lines
the problem is that you are trying to put movement (which is a vector2) into vel.y which is a float
I was under the impression that movement was a float for some reason
i think you can use vel.y = movement.y
let me know if this works
ALSO - make sure to write FixedUpdate correctly using PascalCase
Any luck?
@inner vine if it doesn't work please try to use the following: https://hatebin.com/kgtcgczqnf
make sure to change the class name to your script name
on witch line?
You're having some basic structural issues with your code. You should go through some basic C# tutorials so you understand what on earth you're looking at
currently I guess the code looks like wingdings to you
there are no line numbers in the screenshot but i counted 20
can you send me a link?
try to replace this code with the hatebin i posted
remember to change the class name to your script name
Loks like you're just missing a closing brace at the end of the file
this?
you should really read what that the compiler is saying, too... missing brackets and semicolons are easy things to fix and very evident
from the error messages
what errors are you getting?
thats all the errors
ok, try this - select the scripts name and press Ctrl + R, Ctrl + R (twice). then remane your script to Movement. then place it on the object again
hello?
rename*
OOF man im hungry
on line 16, change RigidBody to RigidBody2D
what
rb = GetComponent<RigidBody2D>
im luaghing rn
rb = GetComponent<RigidBody2D>();
15
the <>?
so many FRICKING ERRORS
did you save?
clear the console
in visual code
most of those are from 10 minutes ago
then this is the only error
show me all of the script
i already did
still errors?
it's Rigidbody not RigidBody
look at the field called movement speed and set it to 5
oh you are right! so set both lines to Rigidbody2D
press on the Movement component to expand it
then set the speed to 5
and THEN see if it works
yessss
its still normal speed
glad to hear it
are you sure it wont mess up the tutorial im using? ._.
Run, Player, Run! We look at creating a player movement script for a 2D Platformer in Unity. This is the second part of our 2D Platformer in Unity series.
Thanks for watching!
Twitter: https://twitter.com/tyler_potts_
Go check out my main channel: https://youtube.com/c/tylerpotts
I aspire to be an Indie Game Developer making fun and immersive...
if you are using a tutorial, wouldn't it be simpler to just see what they did to make things move?
🤓
☝️
so just copy the script?
i decided to redo the whole movement code
uhhh
hello?
ive redone the code so it follows the tutorial and its saying: The variable rb of Moving has not been assigned.
i need help
pls
So assign it. This is basic Unity stuff.
Also, if you're following a tutorial, follow it.
Hello, i got a quick question
So I have a situation where you can pick up objects with the mouse and let them go by releasing the mouse
Right now, wherever the player is at you can move the pickup object anywhere on the screen
Is it possible to limit where the pickup can be moved to? Like, make it so you can only drop it within a certain distance of the player?
This is my current code for the picking up: The script is attached to the pickup object
Sure, though it would take a bit of work.
The idea is pretty straight forward though:
- Get the distance between the mouse and the player
In Range:
- If it's less than a value (range), then allow the position to match the mouse as normal
Out Range:
- If it's greater, than get the direction to the mouse from the player
- Normalize that direction and multiply it by the range value
- Set the position of the item to be the playerPosition + direction
So looking over my code, literally the only thing that stops my horizontal momentum/movement could be the rigidbody/collider's collision. No code(on my side) involved.
What could be the problem here? It runs smooth over a random number of platforms(anywhere from 1 to 50), maintaining a constant speed, and then eventually gets stuck on the next/upcoming platform until i drop said platform down a pixel.
i just checked the rigidbody.velocity.x and it is cycling between 10 and 0, due to my code accelerating it to 10 and the rigidbody decreasing it to 0 so it doesnt clip. Does anyone have an explanation why it is colliding despite clearly not crossing the other collider?
for reference, if i jump, he continues as normal, and eventually gets stuck again. the platforms are transform.position changed only in the x dimension, endless-runner style
oh wait
i have a quick question and i could'nt find anything in the web, do anyone know if there is a way to make an object always point upwards undependently of his parent rotation?
not quite sure how to word this, but is there a way to attach one gameobject to another during runtime? I don't mean like nested objects, but rather taking two independent objects and forcing one to follow the movements of the other
like making one the child of another?
i think that will work
oh dang, I can do that? Rad
how
i know nothing about unity
also, not sure if I can answer your question @terse thorn , but how do you have your object set up? Is the sprite attached to a nested object on the one that's rotating?
the object i want to keep pointing up is a child of the object is actively rotating
Please do the tutorials pinned in #💻┃unity-talk before posting here. All beginner tutorials will teach you how to use Unity and assign stuff in the inspector.
i tried putting in some good effort to explain my problem, anything im missing that would be helpful?
i had this exact same problem a year ago when i gave up on learning bahaha. different platformer prototype, same issue
well i have a current workaround where it checks if velocity is 0 and moves the player up .000000001f and it fixes the issue fast enough that you dont notice him stopping and resets the velocity to 10. idk man it just sounds like a unity problem to me considering all 3 platforms are spawned in the exact same Y position and it randomly decides to get stuck, changes every time.
what's your actual problem?
my dumb question is do you have the Rigidbody assigned in the inspector
have you set movement speed in the inspector?
nvm im just stupid
are there errors in your console?
nah its still slow
ah ic
is it imposible?
@inner vine Don't post gifs.
@terse thorn https://answers.unity.com/questions/1360351/how-to-rotateposition-the-child-object-independent.html theres a workaround mentioned in this, i think he mentions there is no direct way to do what you are asking though
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
:(
the workaround should work fine though, i actually came up with the same workaround for my old project a while back
how the frick did i not read the rules
me dumb
you got this my dude, no stress
and also i read rules now
wait who were you talking to?
oh frick i forgot
im getting these errors
the code
can you show the numbers on the side as well
the tutorial's code
jumpforce has a : not a ;
what
you have a : on line 9, not ;
public float jumpForce = 20f:?
should be 20f; not 20f:
i prob should go back to the tutorial
dang i cant jump still
frick why cant i jump?
are the buttons assigned properly in unity?
edit > project settings > input manager is already configured?
oh jump is default, guess its spacebar default?
does any movement work and just jump doesnt?
its ok im thinkin bout it
you are using spacebar right? and edit > project settings > input manager > axes > jump is configured correctly?
thats all i can think of
unless maybe your collider in unity is huge and getting stuck in stuff, idk
sorry, im pretty scrub so idk
thats all i got buddy, idk what the problem is. tried looking it over but im too scrub to figure it out 🤷♂️
maybe send a screenshot of the movement script in the inspector for good measure though
moving script* in inspector, on the gameobject
you mean the player?
yea
something wrong here. the script you sent was "moving" but the script on the player is "movement"
so either way, you gotta add the "moving" script to the player gameobject
OH FRICK
THEN ITS THE WRONG SCRIPT
i had a script named movement but i was not planing on using it
i was actually gonna delete it
thats why
frick

dangit
NO WONDER
yea after swapping scripts, youll need to reassign the scripts variables in the inspector ye
hopefully it works now
the reason why that script was there was bc my power went out
and i forgot to save
also im fricking dumb and idk how to do that
let me guess more coding : (
in unity > select the player > look at inspector > look at "moving" script > see "none" in the rigidbody variable > drag the "rigidbody 2d" in said inspector window into the "none" space
could be wrong on that one, and if im wrong, then indeed it takes more coding
select the player means the model right?
select the player gameobject in the hierarchy or the scene yea
something like this basically. there should be a "rb none" space in your "moving" (script) that you drag the rigidbody 2d into
but idk if that works tbh
i just assume it does
yup
imo before continuing any tutorial i have a recommendation
im basically fresh out of this tutorial series
probably the best iv ever taken
In this official course from Unity, you will learn to Create with Code as you program your own exciting projects from scratch in C#. As you iterate with prototypes, tackle programming challenges, complete quizzes, and develop your own personal project, you will transform from an absolute beginner to a capable Unity developer. By the end of the c...
be patient and literally watch the videos and try and understand what is going on BEFORE you do it yourself
if you rush then it wont sink in and youll forget steps down the line
i had college classes and boot camp classes related to programming and they wernt as good as that series, legit
i want to learn unity when im done with the tutorial so i can add my own spins to it
so no thanks for rn
i want to make the basics before learning
eh this series is legit a steal, i'm surprised it doesn't have a pricetag
anyway good luck yo
ok ill ask when i need help
Hello, can somebody help me with something. Right now I'm trying to implement some enemy awareness (detect if the player is behind a enemy, etc.) So this is my code for when the enemy detects that the player is attacking from behind. My issue is that the condition always throw a 1, and that makes the enemy rotates every time the player attacks him. How can I fix that? Is there a better implementation of the problem?
VS Code should be properly underlining that error in red
https://code.visualstudio.com/docs/other/unity it mustn't be properly configured as it's not doing that
wat
Also, the error tells you what line of code it is, so you can look to that line for the issue
which is this
it should show a red underline where the issue is
it doesn't, meaning your IDE isn't configured properly
also, read the error, look at that part of the code, and think about how the two might connect
ide?
VS / VS Code
bruh the problem is THE FEET
?
there is meant to be a feet thing here
#🖼️┃2d-tools message is the problem. It's pretty clear what the issue is, and nothing I've said is incorrect
The code cannot compile
so it will not show any new values in the inspector
how do i fix it?
also dont show me a lesson thing rn look at #🖼️┃2d-tools message if thats what you are thinking to do
how do i fix?
What is that error I just posted talking about?
what character is it saying is missing?
yahuh
again, with a configured IDE it would be underlining the issue as you write the code
idk how
If that is VS Code then you need to follow all of the instructions https://code.visualstudio.com/docs/other/unity
is that right? or is it just a download for visual studio code?
Do what it says? It tells you what you need
Guys, can you help me with my issue ☝️
does it mean run that command?
no, it says to install it, and tells you briefly what that includes
ah frick i have to restart my computer
while im gone help this guy
cya
back
uh oh
was i meant to do a command
?
im missing a ; in my coding and idk where it is where is it?
https://www.youtube.com/watch?v=ZvF_MYlt944&ab_channel=MuddyWolfGames is all i can give
Run, Player, Run! We look at creating a player movement script for a 2D Platformer in Unity. This is the second part of our 2D Platformer in Unity series.
Thanks for watching!
Twitter: https://twitter.com/tyler_potts_
Go check out my main channel: https://youtube.com/c/tylerpotts
I aspire to be an Indie Game Developer making fun and immersive...
nvm i just had to hit save im a walnut
classic misstake
pls help ._.
bruh
B R U H
H E L P
@inner vine Looks like the first line of IsGrounded, but if you editor isn't telling you that you need to stop and fix that
you'r*
@inner vine Don't spam this channel please.
witch line?
Hi guys,
I am making a 2D game just like Terrarian.
I see there are two options for player movement now
- Use kinematic Rigid Body and self-control player position
- Use dynamic Rigid Body
What is the Pros and Cons of that?
what am i supposed to do
I got this problem here... I make the white ball track the mouse by adding movement towards it, then the camera tracks the white ball. I also made the player(dynamic rigidbody) able to collide with the static wall. I want to make it so the white ball can crash against walls so people can't zoom past them, but it's already got a dynamic collider and it isnt colliding against the wall. However, it does crash against the player and can even move him around, which i definetevely do not want. How can I avoid this, while making it collide with walls?
f(Input.GetButtonDown("Jump") i have this code, i wanna jump with W but i dont know how to make it
if(input.GetButtonDown("w")
not working
do if(input.GetButtonDown(KeyCode.W)
hey so can I see the code which makes the circle go to the mouse, dm me, or did u fix it
did it work?
the circle following the mouse isn't what's broken but here you go
oh
u are setting the position of crosshair to mouse position
not moving it towards it
does the crosshair have a rigidbody on it
lol
i thought i'd done that lol, i'll do it properly later
the crosshair does have a dynamic rigidbody with 0 gravity
You'll have to start moving it with forces or at least setting velocity
dm
use rigidbody.moveposition
Setting position directly will ignore physics
but anyways i think that explains why its not colliding, its mo-
yeah exactly what he said
i'd swear i set it to moveposition
but i only did that for the camera
hello, i need help for a little problem (for you i think but big for me)
I make a system to save and load, But when i load my game after quit, The game load lvl but dont load music and my canvas with my deathcounter,settings button fadesystem and other thigs, how i can load this to ?
silly me
You just need to make sure those things initialize properly when loading the game from a save
Normally alot of those things would just be in your scene and not related to the save load system
hum so if i make in any scene this , no problem ? but i use DontDestroyOnLoad, so when i make them on scene a have 2 time sound and other things
cause i didnt find other system for having my audio and my deathcounter on everyscene alltime, if i dont do that they reload at ever scene
im not sure if here is the place to ask- im a bit new here
but im trying to use cinemachine, but for some reason the camera keeps pulling wayyy back as you see in the ss
and i cant modify the camera either soo what am i doing wrong here?
ermmm anyone?
cant help you sorry
can you point me to where I can ask this where someone might know
let the time here to ppl read and wait like me ^_^
Question, how do i access IsMine in GridElement.cs using the coord?
from Populate.cs
yea but you need to create a public
public GridElement instance ;
private void Awake()
{instance=this;}
within GridElement?
and with that you can use instance on your script
in your GridElement script you need to create this instance
for using IsMIne on you other script
im having trouble understanding
both the reason for "instance" within a script, and the definition of instance
hum. instance is used for take something on your script for other script
so if on your GridElement you creat this void for instance
you can use your IsMine on your script Populate.cs
does that mean, i have to create another class to take in xcoord & ycoord?
to return true or false?
where is your "mineCheck"?
GridElement script?
ok so your mine check is on isCellMine
do you creat the void awake instance?
uh, no?
you need it, if you dont create this public GridElement instance ; private void Awake() {instance=this;} you cant use your isMine
if you want to use something to your script GridElement on other script
you need to do GridElement.Instance.isMine for exemple
so you mineCheck is what?
you use mineCheck somewhere?
basically, it's a code to check the surrounding coord if there's any mines, if so, add 1 to the counter, and after double forloop is over, it will print out the total of mines into the cell
and on your error can you show me the line Populate.mineCheck ?
and on GridElement.cs you have my private void awake instance=this; ?
its instance not Instance
problem still remains the same
btw did you link visual studio to unity ? you have lot of things on white and no error return
i did?
i opened the script from unity, and it just open the script on vs
or am i doing it the wrong way?
and you quote mineCheck=gridElement
he dont know what is mineCheck
cause is quoted
mineCheck=gridElement.instance.isMine(row,col)
well, i didnt know which kind of code am i suppose to type, in order to get isMine from gridelement, so i typed it, and due to error, i quoted it, for at least i know where to work around with and from
btw your if i think you dont need it, cause you make if its true=true, else false=false
after maybe my explication is really bad cause im not really good at english and not pro dev atm :/ so i hope other one can help you more than me.
jsut for me you need instance for using your isMine to your script for other script
honestly
i have absolutely no clue where in the hell am i trying to write this code, or what so ever, because my fking lecture wanted this code to be in this way
i think you have prob with your minecheck
because in my brain, i have no idea how am i suppose to implement it
anyone mind helping me out with stupid code? 😄
i created a new scene and i can still see the old scene?
do i have to add or remove something?
Can anyone help me set up player animation for a top down 2d game? I have all the sprites just need help with the technical aspect (inside unity)
is this just not a possible fix?
or do I need to edit the camera or something?
did you select the old scene after creating it?
no
@rapid ibex
Wait would moving the camera in the new scene work? That seems wrong though, cause then it would still be generating the old scene at the same time right?
try just deleting the new scene and making another new scene to see if it fixes it. you can select the camera to see what the camera is showing on the bottom right to see if it's showing nothing in the game view like it should be or if its still showing whats in the old game. if worst comes to worst you can delete one item from the new scene and see if it affects anything in the old scene, if it doesn't affect anything in the old scene then just delete everything in the new scene
I haven't put anything in the new scene and I've tried all of the things. The new scene's camera displays the same thing as the old one's, execpt the bg color is different because I changed the old scenes bg color
Just to be clear, how are you creating this new scene?
And how are you opening this new scene?
And then I grabbed it and dragged it up
Right, so this is a misunderstanding of scenes.
then I clicked on it and the camera bg color changed
Scenes are just containers for game objects. You can have multiple of them in the hierarchy.
If you want to edit a scene independently, just open it up from the project folder.
Just double click the scene in your Project folder to open it up.
i don't think I have made a project folder
oh
It's where you've been dragging the scene out into the hierarchy. Instead of dragging it out, just double click to open.
If this is all new to you, you should consider doing some beginner tutorials. This is basic Unity workflow stuff.
37
I'm trying to get my character to be pulled toward a branch when near one and when he holds down the right mouse button. the check is to make sure he is in range of the trigger in order to use the ability, but the best thing that happens when I press the right mouse button when in range of the branch is that it teleports me back to spawn.
I'm mostly unsure how to make the tether pull me towards that specific branch in range and not towards one of the other branches that are set as a prefab.
You can use the Collider2D parameter from OnTriggerEnter to save a reference to the branch
im not sure how you would go about doing that, nor am I super clear on what you mean.
I feel like I understand what your saying but I'm unsure how to pass the location of that specific branch when entering the trigger zone. I was thinking having an empty game object in the center of the branch but I'm unsure how to pass the location of the nearest branch
i lost sight of the play area what do i do?
thank you
np
a especific bullet is not dealing damage, while other bullets damage the player as normal
code anchored to the player gameobject
https://pastebin.com/06bS1jwW
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.
Look at what kind of parameter it requires
Compare that to what you are passing into it.
the first field goes like (Vector2) forceDirection * (float) forceamount
ok
I need help finding where I went wrong with this code, I'm trying to make a shooting system
@coral dock first line in Update(), UtilsClass.GetMouseWorldPosition, you need to add the namespace wheret the UtilsClass exist, or it might be your project is missing the UtilsClass script
can you post the UtilsClass, looking at the error in console, unity cannot find the UtilsClass, so either the namespace missing or the script itself
@cinder valley whats the error/issue you're trying to solve?
well... um... it shoots... but it just appears and immediately disappears
okay makes sense, in your Bullet_script classs, FixedUpdate(), rb.velocity is being set every frame
and its not frame independent, you might want to multiply the movement with Time.fixedDeltaTime
in the FixedUpdate? I'll try it, thank you
also give rb.MovePosition a try instead of rb.velocity
hello, i have a prob when i load my game, i une script for checking doublon, everything works execpt my canvas ... he destroy it.
MissingReferenceException: The object of type 'Text' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
can you post the complete log
the log?
errors
semicolon missing on line 12
move position is a method https://docs.unity3d.com/ScriptReference/Rigidbody.MovePosition.html
thank you
what would i put for input if i wanted the animation to play when i hold down left click
right now its just click i cant hold
how would i go about doing that
idk i use bolt
@lilac folio If you don't have answers, please don't spam the channels.
ok
@coral dock You can flip a bool on ButtonDown event and then wait for ButtonUp one to release it.
@coral dock you can get the events with GetMouseButtonDown & GetMouseButtonUp, so between Down & Up, you know the player is holding
like this?, sorry very new to coding
you have duplicate checks, but yeah this should work
lol look
no that wont work, you can trigger your hold anim on Down, and stop the hold anim on Up, but make these 2 separate if checks
and ofcourse you can play your shoot anim on Down
so the one i currently have will trigger it?
yup thats right
but as of rn when i click in game or hold it plays the animation once and wont loop it
im looking to loop the animation until i stop holding
try looping the animation and stopping it when you stop holding the mouse0
yup, think you're using mecanim, it does have looping flag to enable
Additionally, if you want to make sure that animation loop finished playing, you can use animation event placed at the end of the clip timeline to check if it should flip looping state or just interrupting animation.
how can i create a global float timer variable
is this for setting the firing rate?
missing semicolon
I'm building a game that looks like WhatsApp and I have added the functionality to pan and zoom images. I'm wondering how to add inertia to an image, so that when the players pans the image, the movement doesn't stop immediately as the player releases his finger from the screen but decelerates after the finger is released and slowly stops to move. How can I create this effect?
Codify the physical properties such as velocity, acceleration, and inertia and simulate them over time
I've added a Rigidbody to the image game object and put this in my code:
if (Input.GetMouseButtonUp(0)){
rb.velocity = direction * 2.5f * time.deltaTime;
}
It still doesn't work but I hope I'm going in the right direction...
hey how do i make animations more snappy? is it just a case of adjust the animation time or are there some settings i shouldf be using?
Doesn't seem like the right direction. You don't need to use the physics engine to just get a basic velocity/acceleration paradigm. Also that code doesn't make a lot of sense
Snappy is a really abstract concept. But generally just increase the speed of the animation.
thanks it's just for punches with are two images.. it just seems when i attack it doesnt keep up with me if you know what i mean.. i'll try adjusting the animation then 🙂
is has exit time a thing for a retro pixel game? I dont think i need any smoothing between animations right? as it's just images
It's a thing. That will determine how "cancelable" an animation is
So I took a screenshot so u can see and im very new to any coding lol so it might not be right but I'm trying to get my player (red square) to fly (hit the roof) when I click space bar but it comes up with The referenced script on this behaviour (Game Object 'player') is missing! Any 1 know how to help
make player into Player, first off
As the code you might have wrote could have been defining Player, instead of player
i try many things but i always have my bug, he dont find my text and give me error on my script. btw when i dont load the game everythings works. just the load of games bug :/
oh I might understand the error. @grim coral
have you put/drag the script PixelMovement on your player?
it says "The referenced script on this Behaviour (Game Object 'player' is missing!". It is as the engine is saying your player don't have the script on it.
This came up
I fixed it by changing the name but now it just moves constantly horizontal and down until it hits a spike
anyone here know if they could help a fellow potato who does not know hot to code?
._.
Have you put a rigidbody and box collider for your game floor 2d?
What u trying to code
In your code in update. You move the character at 2 different place at the same time.
This might cause some bug
If anyone can help, I want to add a system where if my coinvalue equals a certain amount then an object would be destroyed
So i had this problem where my Vector3.Lerp is faster on a bigger screensize. I added divide by Screen.width to the Time.deltaTime counter. but it still doesnt seem to change the speed on a bigger screen. Im really lost atm and have been trying to fix this problem for hours
Ive debugged the screen widths and they are different.
How would someone change their characters sprite, like if they transformed
change the sprite on the SpriteRenderer?
Or swap out the entire player prefab
I have a question that I can't seem to quite figure out. Lets say I have a starting point, city 1. When I place down city 2, I want a line renderer to be drawn between city 1 and city 2 dynamically. What would be a way to do this? If you could point me in the direction.
Right now I have a main city. I'm able to instantiate the smaller cities, just stuck on how to draw a line between them properly
line.SetVertexCount(2);
line.SetPosition(0, city1.transform.position);
line.SetPosition(1, city2.transform.position);```
assuming line is a LineRenderer
Oh ok thank you! Yes I am planning to use a line renderer. So, if i'm going to have multiple outlying cities all connected back to the main one. Does that need to be only on the outlying city scripts so they always connect back?
You want each of them to have a line connected to the main one?
You could do it either with one linerenderer per non-main city
or get a little more complicated adding a lot of vertices to a single LineRenderer
e.g.
maincity -> city1 -> maincity -> city2 -> maincity -> city3
Ah ok, I think the best "maybe" would be for each outlying to have its own.
stupid quick sketch example of what i mean.
Ok thank you for the help!
yeah
Got it working, is there an api to call a texture for it? It creates a line without a texture bahaha
Yes the LineRenderer has a material field
you can put any material there you want
Correct, I'm talking about it doing that from code. I have the code creating the line renderer, but when it does it doesn't assign it a texture for some reason.
Wait I'm dumb, I can do a public materail.
alternatively, put the LineRenderer on your prefab in the editor, just disabled
then you can freely configure it from the editor
and just enable the LR when you place the city
Got it working, just trying to figure out how to call the material via script.
Hi! I am making a 2d platformer and I was playing arround with the classic mechanic of jumping ontop of an enemy to kill it. But I am having a problem. I have given my player the "player" tag and I have created an empty game object with a box collider as a children of the player with the tag "player feet". Then in my enemy I have added an OnCollisionEnter2D that checks if it has been hit by another collider with the tag "player" then do damage to the player, if it has been hit from a collider with the "player feet" tag then get destroyed. The problem is that it doesn't get destroyed. I have checked the tag (player feet), I have renamed it , i have put a diffrent tag but still it doesn't work. What am I doing wrong?
where to start learn unity scripting
Pinned resources in #💻┃code-beginner
i need help cause im little bid colort blind can get a piskel hex code of brown pls
is this brown?
definitely brown that one
if I can see your script i might be able to help you
also i think this is a bad approach since the player feet could hit the side of the body
I think you should have the player feet but also a empty gameobject with a collider that is marked enemy head
then if the player feet touch the enemy head you can destroy it
i got this error while sprite edit
hello, im trying to make a bomb that destroys tilemap "objects"
Heres the code but i dont know why is it only destroying 1 tile, can i get some help?
A few things going on here that can be fixed. Not sure which one is specifically causing your problem. For one, I think you're misusing collision.contacts
I mean the idea of it. .contacts gets you the contact points of a single collision
It's probably not the sort of thing you want to use for colliding against many objects
what sould i use?
raycast a circle and destroy the tiles inthere would work better?
Yeah something like that
https://docs.unity3d.com/ScriptReference/Physics2D.OverlapCircle.html
ok im using collisions cause i wanted to push back other stuff but i need thrse object in tiles for the navmesh so im gonna try this thank u
Whoops this one is more suitable**
https://docs.unity3d.com/ScriptReference/Physics2D.CircleCastAll.html
Gotcha, if you want to push stuff back, you can still apply forces to them after detecting them via the CircleCast
but i would have to calculate a direction for each XD
lol true
You could always use
https://docs.unity3d.com/ScriptReference/Rigidbody2D.AddForceAtPosition.html
How could i compare two colliders so when they collide something happens?
Also the script is in neither the colliders, its in a overallcame controller
Unity only sends Collision messages to objects involved in the collision. So you'll need at least one script on one of the objects involved in the collision
You can use that Script to notify your game controller though
How can i do that?
Call a function on your gane controller from inside OnCollisionEnter in a script on one of the colliding objects
Ok ill try it
Assets/Yarisma.cs(31,20): error CS0178: Invalid rank specifier: expected ,' or ]'
Help pls
@floral flame Use a proper code sharing site like hatebin.com
Atop spamming and cross posting
And then ignoring people who are helping you
Also don't crosspost in the future.
Stop spamming and cross posting
pls how to make controls like
A-->left
D-->right
Spacebar-->jump
What have you tried so far?
this is my problem, a especific bullet isnot dealing damage, while other bullets damage the player as normal, this problem is so confusing and some help will be awesome
code anchored to the player gameobject
https://pastebin.com/06bS1jwW
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.
Hi again
im trying to make a bomb that destroyes tiles
i tried checking the objects with collisions but dindt work then i got a sugestion to use a raycast instead
but just now i realized that the tile map obejacts are all under 1 collider
thats why it just destrying the first tile it collides with i guess but detecting all
how can i make this destroy all the tiles inside he raycast instead? without checking for collision just and offset in every direction?
I have a code that spawn particles but the color of the particles is doesn't been updated.
That's what I have done and it doesn't work
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "player feet")
{
Death();
}
if (collision.gameObject.tag == "Player")
{
GameManager.GetComponent<DamageCalculator>().TakeDamage(1);
}
}
this is the part of my script that handles the collision with the player
See if switching from collision.gameObject.tag to collision.collider.tag does anything for you
it fixed it. Thanks!
I was only about 10% confident that was your issue haha
the problem is that collision.gameObject gives you the GameObject that the Rigidbody is attached to, which may be a parent of the actual collider
hello, how i can load my canvas to all scene,.? i have a deathcounter on my canvas but i cant make him on DontDestroyOnLoad cause if i do that when i die, game crash cause he cant implement the death
I'm having some oddities with a 2D sprite animation looping that I don't want to loop. I've unchecked Loop Time on that animation, which seems like the most common cause of this, but it's not stopping my animation from looping. This is just a simple Unity animation with an animation controller. All my animation is doing is periodically changing which sprite is rendered in a sprite renderer.
Oh nevermind. I'm a dolt.
I forgot to disable "Can transition to self" for that state.
How would one go about accomplishing a Photoshop-style additive blend mode for a sprite in URP?
if i use dontdestroyonload for my canvas, he cant implement death so dont work
hey guys, im making a 2D game and when my player collides with ground which is higher, then it rotates, and i dont want that, please can someone help me?
pliz
Can anyone help me with 2d Tilemaps
i have a procedural generated map and i just want to get a few chunks around the player loaded
Send me your code i can try
I´ll have a look
okay
click on your player > inspector>Rigidbody>freeze Rotation Z
maybe could do it
and i would change the line 19 from movement to movement.x
can ask me if you need help
oke, can i add you?
yes