#πΌοΈβ2d-tools
1 messages Β· Page 30 of 1
Yep
You could either duplicate that and edit it via code, or you could use Shader Graph to make your own sprite shader
I can help you with either
I don't think so, I doubt you can do that with animation. I mean you can combine both animation into one. It create an animation blend tree and transition between them maybe
Please help meπ , I been trying to figure this out for a couple of days.
Have you ever used Shader Graph? If not, I'd probably go the route of editing the shader directly.
How can i combine both?
Well these couple of days I been looking into shader graphs, I don't understand much, but I can connect nodes tho π π
Probably editing it then?
As in for example scaling the object and at the same time rotating it. Something like that.
But tbh which ever is easier for you.
I'm not 100% sure it can be done in Shader Graph, so I'm going with editing the shader.
okay
Here's the source for the default shader:
https://github.com/Unity-Technologies/Graphics/blob/master/com.unity.render-pipelines.universal/Shaders/2D/Sprite-Lit-Default.shader
Start by copying everything in that file and paste it into your own .shader file in your project
And give it a different name, both in file name and in the first line of the shader
I'm making a new URP project so I can make sure all the steps are correct. Just a second.
thank you so much for this, i really appreciate it
@winged kiln I've modified the shader and it's working sorta
https://hatebin.com/vtqitymizl
But it's still a tiny bit visible if the green sprite is also casting shadows.
If it isn't casting a shadow, like in your screenshot, then it's completely invisible.
nothing will cast shadows except the red sprite which in my case the wall
but what did you change in it?
BUT THANK YOUUUUUUU
I REALLY DONT KNOW HOW MUCH TO THANK YOU
thank you so much, you dont know how much i been looking into that
No problem!
I found some shader functions for sampling the shadow map and found this shader that does it:
https://github.com/Unity-Technologies/Graphics/blob/30d75d046a2d57ccf268c863476808514a4086a4/com.unity.render-pipelines.universal/Shaders/2D/Light2D-Shape.shader
Things like SHADOW_COORDS(TEXCOORD1), APPLY_SHADOWS(i, color, _ShadowIntensity);. These are all helper functions to draw shadows, but I don't think they're documented.
So I copied those and put them in the same place, then the main part is this:
half4 shadow = saturate(SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.shadowUV));
main.a *= 1 - shadow.r;
I'm doing this at the end of the fragment/pixel shader. Sampling what the shadow intensity is at the current pixel and multiplying the alpha of the main sprite color with 1 - shadow intensity
So if the shadow intensity is at 1, then main.a *= 1 - 1 = main.a *= 0, so alpha becomes transparent.
ohh i see
i will have to look more into shaders, and try to understand them
but thank you again tho, really thank you
it does still give me this, but i think that should be fine since it would be away from the screen
Looks like the shadow mesh only extends as far as the light radius
@winged kiln It's actually simpler than I thought to do in Shader Graph as well
Just need to create a texture property with the name _ShadowTex to reference the global shadow map texture and sample it with the screen position
Then you do the same logic, multiply the alpha with 1 - shadow.r
how do i reference the global shadow map?
also for some reason my shader graph looks different then yours.
is it because of the version of unity?
Could be, I'm on 2020.1
You just need to create a texture property and make sure that the Reference name is set to _ShadowTex. The other settings don't matter but I wouldn't have it exposed since the user isn't supposed to assign it.
okay
Then you sample it like any other texture, except instead of using UV0 as the UV, you use the Screen Position Node
Does it have Vertex and Fragment stages separated?
yep it does
when i try to have reference on it, it doesnt show that option
so am searching it up to see how to enable it or something
Which option?
When I use the word "reference", I just mean referencing it by name, which is "_ShadowTex"
You don't need to find the shadow tex anywhere, that property will be set to it automatically so long as it has that exact name
Because it's a global texture
yea i know, but you see how you have Shadow Tex and in reference it has _ShadowTex? i dont have that for some reason
yea
let me do that
oh wait, its in the node setting in another window smh lol
lol
they moved it to the graph inspector π
did i do something wrong? the sprite went back to normal
oh wait, it works nvm, it was my fault
if you dont mind me asking, why do you do one minus only on the red channel?
@winged kiln The shadow map uses the different channels for different things
And I'm not exactly sure what data the green and blue channels contain
oh thats interesting
But I know that the red channel is the basic shadow or not shadow channel
Where more red is more shadow
where do you learn all these things π
thats pretty cool tbh
I inferred it from the shader code that uses the channels:
#define APPLY_SHADOWS(input, color, intensity)
if(intensity < 1)
{
half4 shadow = saturate(SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, input.shadowUV));
half shadowIntensity = 1 - (shadow.r * saturate(2 * (shadow.g - 0.5f * shadow.b)));
color.rgb = (color.rgb * shadowIntensity) + (color.rgb * intensity*(1 - shadowIntensity));
}
Its clear that the RGB channels aren't being used as colors here because they are being used strangely
Also, colored shadows doesn't make sense in the first place
i see
thank you again.
do you mind if i dm you if something comes up with the shader? am not going to trouble you much
@winged kiln Sure, I don't mind.
thank you
am about to crash because its 4Am where am at
talk to you later, thank you again
And how can I use data base for my game?
Have you used SQL before?
hey can any one help me i cant get my states to work for my animationhttps://paste.myst.rs/a65skhnk
a powerful website for storing and sharing text and code snippets. completely free and open source.
I am using this code to make my player move. Is there a way to delay the input a bit so that the player moves for a few seconds even if the button isn't pressed anymore?
You shouldnt be doing your Input polling in FixedUpdate
Put it in Update. the only line that should bein fixedUpdate here is the rb.MovePosition line
If you want that, i think you want to use rb.velocity
Because MovePosition i think is teleport movement
Move position should be fine if he's moving in small increments. However the input should definitely be decoupled and handled in Update.
Hey can anyone help with my script
My animation arent playing
a powerful website for storing and sharing text and code snippets. completely free and open source.
A delay would require some buffer time with either timer, invoke later or coroutine.
Is there something wrong with my script
Dalphat. You only speak / write english?
I definitely speak and write English but am not limited to English. That should be enough to communicate over the Unity Discord Server. Why?
I'm doing localizations and wondered if you would be kind to just go over the google translate and make sure its not trash?
Depends on your language though. And if you want to do it. Completely fine if you dont π
Aaahahaha, non programming languages aren't my forte.
Aaa ok i see, perhaps i should of worded it better
Hello, is it possible to change sprites inside animation at runtime?
For example, I would like to re-use this animation, but with different sprites
why would you want to do that?
This animation just switches sprites, there is nothing special to reuse besides the sprite itself
I have many spritesheets that have the same animation layout, and I would like to use those spritesheets without creating many .anim files
I think there was something named rigging, but I donβt think you can change animations in runtime
yea same ^^
why not create your own animation system?
i mean all it does it goes through some sprites at a certain rate per second
yeah, instead of using animations, just switch through your sheets and jump from position A1 in spritesheet 1 to the same in 2 for example
I am thinking of doing it, but I thought maybe there is more elegant way to do it
You can also work with alternate sprites for one sprite, I think
yea, simple sprite animation is very simple in unity tbh
i mean tbh it looks like the hue is different, so maybe change the hue in code through shaders?
well, that's just an example
I'm planning on using spritesheets that have different size and sprites
but still keeping the 3x4 layout
I would write my own animation system for that, tbh. Fiddeling with unitys build in one which actually just jumps from sprite to sprite in 0.1 seconds isnt a benefit for your term, I guess.
alright, thank you for the insights, I'll do that then
i mean and even with the event system, if you do your own you can just have an index where you just trigger that function, their animation system is pretty easy to recreate in code
yea then you would need to create your own animation system
Yep, and you can easily just jump through your 3x4 layout with different sprite sizes just by dividing it and having an integer of your current position if you need to continue a walk cycle for example.
i would say the complicated part would be to get the sprite texture position in the spritesheets, i dont know how to do that, but there are a lot of smart people here who probably did it already
i dont know how he would be able to divide the spritesheet, it seems interesting to learn, do you know how he would go about doing that?
You should have the size of the sheet or at least one sprite times 3 or 4 equals the height and width, therefore you can just cycle through it.
I'm using Unity's built-in multiple sprite mode to automatically cut out sprites from my spritesheet
yea but how would he be able get the sprite itself?
from the spriterenderer?
well it would be from the texture itself where he might assign, right?
it's a single line of code
Sprite[] sprites = Resources.LoadAll<Sprite>("aliens");
and then when I want to render the sprite from the spritesheet I just index it
renderer.sprite = (Sprite)sprites [3]
so now I need to create animator class somehow
oh waw, so it is pretty simple π€
Why does my player and enemy flies up in the air at collision? They only do that if the enemy is patrolling, i have tried to set a bool
{
patrolling = false;
}
else
{
patrolling = true;
}
if (patrolling)
Patrol();
}
Why do they still fly away? If I comment out Patrol () they don't
What is Patrol() doin?
{
if (mustFlip || bodyCollider.IsTouchingLayers(groundLayer))
{
Flip();
}
rb.velocity = new Vector2(speed * Time.fixedDeltaTime, rb.velocity.y);
}
Just walk π
you are setting the velocity to speed on x axis... is this the player or enemy?
This is the enemy
What are you rigidbody settings? Maybe they dont use gravity?
They are kinematic, so they will never use unitys physics engine, so once velocity is set, it stays that way.
What settings should I use? Dynamic?
This worked for me:
Dynamic
Linear drag 999
Angular drag 999
Thank you so much!
The drag stuff is another story, but yes, dynamic should use gravity and all that needed for your rbs to not fly into heaven π
But when I press play they go back to kinematic, do you know how I solve that? π
Haha, and nope, it did not work, I had just good luck when I tried that time
How do I make my character stop be able to jump mid air, using the Linecast technique but I don't understand it
I'm making a incremental game, but I don't want to use scientific notation, i'd like to make the numbers just have M, B ,T etc, how would I approach this
id make an array of int, each array value is 0-999, when array[0] reach 999, it turn to 0 and set array[1] to current value + 1
that way you can work out with freaking huge numbers
then you just reverse array to a string to get the real number, you know if you are at array[1] it will be the thousands, array[2] the millions
bit touchy mentally but i think its the best way π
eventually as you get in very high number
you can even ditch the first few array row and just increment the later one
hello people, after i implemented coin counter my game broke. after i press A or D, my camera flips - making the "game" unplayable.
in the time i was doing the change, there was also a code with name "~movement (Assets)" that i closed because there were some changes that werent saved so i decided to close it, because i didnt change anything in that code. (also, i didnt find any code with the "(Assets)" in the end)
any help?
Any error? Like we need code to check against, otherwise we won't know what your issue is
int x = 3;
int coins = 1000;
int CalculateCoins(int coins, ref int x)
{
// This will give you 1 for coins when x is 3
// coins / (10 * 10 * 10) = 1000 / 1000 = 1 <-- this 1 can be 1M for example
return coins / Mathf.Pow(10, x++);
}
// Maybe have another function here where it would add an M, B, etc to the end of the
// Text field based on the value of x, if its a multiple of 3 it means its divided by a 1000
// So you can maybe have it so that it would divide by a thousand and every thousand would result in a new letter at the end.
// so maybe something like this:
if(x / 3 == 1) coinsText.text = coins + "M";
// That just means if you have 1 multiple of three then just add "M" to the end,
// you can do if 2 then its basically the coins was divided 1000 * 1000 times. So that can be "B"
// to get the actual value of the coins you would do:
int GetActualCoins(int currentCoins, int multiple)
{
int coins = currentCoins;
// multiple being "x"
for(int i = 0; i < multiple; i++)
{
// if the multple was 6, meaning coins were divided 1000 * 1000 then multiply the coins
// by 10 * 10 * 10 * 10 * 10 * 10.
coins *= 10;
}
return coins;
}
// then you store both the coins value and the multiple value
yea tbh i dont understand it
gimme a sec
should i just copy paste everything there?
or to the direct messages?
Hey can anyone help with my animations my jump and falling animations aren't working is there something wrong with my states in my script?https://paste.myst.rs/a65skhnk
a powerful website for storing and sharing text and code snippets. completely free and open source.
Just wondering, why not use an animator for that?
Hi i have a question. I just imported post processing into my game and now am messing around with the camera filters. The only problem is that now when I try to play my game nothing will happen and im wondering if I am doing something wrong. can someone help?
also is there a way to add image effects to a certain object?
Oh my bad, I just had a quick look at it, sorry. So did you check your states, did you debug log it to know you are in the right state?
This is something for #π₯βpost-processing I guess
Well i am new to unity soooo i have no idea how to debug
o
if you use Debug.Log("Your message " + yourState); for example, you can see this in the console
So debugg each state
Yep, just check that you are while jumping actually in the jumping state. Also check your animator graph if its hitting anything weird or looping only one animation
Soo thanks for the line of code but where do i use ut
It*
Like under my private void Velocitystate()
Or private void update
Or private void start
Where do I put the code
@last surge Give it some testing, you are better with just testing around than making me write the code for you π
Okie dokie imma go start up unity then
Hi guys, i have a question. On a project I am working on I have implemented wall sliding but when I test it my player bounces off the wall instead of sliding. Could any one help pls
i can send the code, any help?
How do I make my score go up when the screen gets tapped π€
Ok I feel like an idiot currently: I am trying to edit an png during runtime an then display it and I just can not find a way to diplay any changes I make? Am I supposed to use a shader for changes during runtime?
^^ forgot I ever mentioned it apparently I have to call apply after setting pixels
ihronn, maybe add a canvas with a transparent panel that covers the entire screen, and then add a button component to that panel. Make a script that has some way of referencing and changing the score which can be done with this
public GameObject ThingWithScoreScript
ThingWithScoreScript.GetComponent<TheScriptThatContainsTheScoreVarible>.score += 1
and add this to the onclick on the button.
hey so i have looked all over the internet to get the simple task of two things happening, getting a bool from one script in another and then getting code to pick a random string from an array. i think i got the bool part down but it either caused problems later on that wasnt in VS or that i just got the random string thing wrong
can i get some help
the array has 6 elements and i need it to pick one
wdym? π€
i mean that i tried to google it and apply the googled knowlege but it still wont work
also i need a bool from one script to be seen in another
and then a random string from an array
sorry
hmm
i think you need public static bool bool_name
and any random string
@empty garden
let me give you for random string
one sec
ok so in my code where the bool originates do i make it a public static bool? will that let me reference it in other code
my internet go brrrr
no not any random string a string from a pre set list array
so like
["one","two"]
sorry
idk
why sorry? π€
maybe i wasnt being clear
ok
int index = random.Next(array.Length);
when i do that Next has an error
random does not have a defintion for next
or yeah
one second
ok
u need to add in top
yeah that didnt do anything
ik
so you have to make a variable
as i gave you
have you assigned variable?
@empty garden
i mean what a rand varible?
yes
i didnt know we were declaring one
there was many ways they told me to use rand.next
so i used it weird
then you can get the string using:-
array_name[var_name];
maybe thats it
this is @empty garden
ok
ok
i am mostly available
idk man i dont know what you are telling me to type becuase it errors out. i even gave array name a string
wait what?
yeah that's not hard
im sorry but your not being clear
this doesnt error
string[] possibleAttacks = { "Cut", "Poke", "Bash", "Block", "Parry", "Grapple" };
thats my array
i cant find out how to make it pick one random one
hmm
ok
let me do it
string[] possibleAttacks = { "Cut", "Poke", "Bash", "Block", "Parry", "Grapple" };
int rand = random.Next(possibleAttacks.Length);
Debug.Log(possibleAttacks[rand];
@empty garden
if this gives error tell me
ok
im sorry btw
yeah
random does not exist in its current context
maybe using time?
buddy you need using System;
it is in System namespace
ok one more way
let me copy that and use another way
string[] possibleAttacks = { "Cut", "Poke", "Bash", "Block", "Parry", "Grapple" };
int rand = Random.Range(0, possibleAttacks.Length);
Debug.Log(possibleAttacks[rand];
@empty garden
are you there?
ye
it says that random is an ambogious reference to system random
and unity random
ok that worked
ty i think i have static reference pulled up ill let you know if i have any trouble with that
ok
ok i got the bool thing done
but wait
ok
let me see
there is no way for me to know if this code works becuase it doesnt go into the debug.loog
wdym?
why it doesn't go π€
if (playerController.playerMoveSelected == true)
{
string[] possibleAttacks = { "Cut", "Poke", "Bash", "Block", "Parry", "Grapple" };
int rand = Random.Range(0, possibleAttacks.Length);
Debug.Log(possibleAttacks[rand]);
}```
ummm
it goes true when i click something in the game
no
update?
well it doesnt work without it but maybe if i put it in update
i forgot i made this its own function
so i need to do something
it can be solved
wait what?
are you using my code or something else?
i did abad
no
hmm
I SEE WHAT AND WHAT I DID WRONG
this should work maybe?
what?
then it should work
becuase what i awnt to do
and didnt do yet
is that later on it will turn off the playerMoveselected
i can do that now
fuck yes its good now
ok
so i think i got litterally all of it from here.
watch me come back soon
ok ok
hi guys is it possible to go to the next scene once the dialogue has ended?
If you're talking about dialogue you control, ie it's regulated in a script, just make a line of code that loads the next scene using the scene manager;
this goes at the very top;
using UnityEngine.SceneManagement;
Then, you can access it through code once your dialogue is done;
SceneManager.LoadScene("name of your scene");
or, if it really is the next scene in the index, you can use the index number on the scene list in build settings;
SceneManager.LoadScene(index number);
I hope this was what you were looking for!
thank you so much !
why does this happen?
public class Adebug : MonoBehaviour {
public Object testObj;
public Sprite local_button_s;
private Texture2D local_button;
void Start () {
local_button = new Texture2D( (int)local_button_s.rect.width, (int)local_button_s.rect.height );
var pixels = local_button_s.texture.GetPixels( (int)local_button_s.textureRect.x,
(int)local_button_s.textureRect.y,
(int)local_button_s.textureRect.width,
(int)local_button_s.textureRect.height );
local_button.SetPixels( pixels );
local_button.Apply();
}
// Update is called once per frame
void OnGUI () {
GUI.skin.button.active.background = local_button;
if (GUI.Button(new Rect(35, 80, 121, 56),""))
{
Destroy(testObj);
}
}
}
Hi, I 've done 2D platformer character controllers before, but now I'm making a new game, where want the player (the circle) to roll like a wheel and move around rolling
But I can't figure out how to do it
If i rotate the gameobject itself, it doesen't move at all
@normal jolt how do you rotate it?
are you using the rotate function of a gameobject, or the rigidbody2d? ie Addforce, or are you just rotating the gameobject using the rotation xyz?
I', doing it using the transform, but it doesn't even matter because it doesent work
transform.eulerAngles += new Vector3(0, 0, 1f);
Bc in 3d, using gravity and an object with collision and friction, an object will naturally roll. I don't think transform gives it any physical movement, it just rotates the applicable gameobject.
Where can I learn more about the difference between using transform, using rigidbodies e.t.c.? because I've been using Unity for a few months but I still feel completely new when it comes to working with this kind of stuff.
yeah, me too. As far as I know, rigidbodies pay more attention to collision and friction, while transform only worries about moving the object.
Watch this video in context on Unity's learning pages here -
http://unity3d.com/learn/tutorials/modules/beginner/2d/rigidbody2d
A Rigidbody2D component places a GameObject under the control of the 2D physics engine. In this video we will summarize the Rigidbody2D component and its properties.
Help us caption & translate this video!
http://ama...
https://answers.unity.com/questions/651984/convert-sprite-image-to-texture.html
this doesn't work for me, anyone know why?
Ideally, you'd use the one you need. If you aren't using Physics Rigidbody, you'll either be using Character Controller or Transform. The docs will provide the available functionalities but hopefully this clears a bit of the fog.
Transform is the standard way to move and rotate. Rigidbody does so using Physics. Character Controller uses RB under the hood.
I think i'm not explaining myself, i did not used any premade character controllers before, I done them myself using rigidbodies, but I used because it was the first thing i thought of, but I didn't really understood the difference.
Between CC and RB? They have different restrictions.
RB you're working directly with forces and velocity.
Okay, i tried using rigidbodies and it works better but not exactly is I wanted
CC is an interface that manages an RB for you. It's supposedly much more easier to jump start applying movement but much more difficult to add/reimplement hidden RB features from CC.
I didn't even know about the existance of cc
Read this for the difference https://medium.com/ironequal/unity-character-controller-vs-rigidbody-a1e243591483
hello
Other than those two, Transform is the default handler for manipulating an objects translation, rotation, scale and the node; every object must have a Transform component.
i need some help with texturing a scrollBar
if someone could help, i would be so thankful
I get it, thanks for the advice @vocal condor
Your image is not sliced, I guess
couple of my friends told me to use GUIStyle
but
the idea of adding 2 textures to 1 GUI style confuses me
#archived-art-asset-showcase is your channel btw, as this is not code related
You are showing a graphical issue and say its coding? π
yeah just wait
so
GUI.skin.verticalScrollbar.normal.background = this.background; GUI.skin.verticalScrollbarThumb.normal.background = this.thumb;
i used this for applying the textures
but this aint the way is it
and these are my textures that i modeled
Still the textures might be the right ones, but the settings on your Image components are messed up, thats what I am guessing
now idk how to apply these both to a guistyle and not break up
Or the settings of your textures
did you compare the standard thumb texture with yours?
the thumb doesnt go outside the bar
the size of the scrollbar can be changed, now the thumb is being streched and contained inside of the bar it self
I'm making a top down rpg, and I need to fetch tiles from an external web api. Which I successfully do, but how do I draw this 64x64 png file to the map? Sorry I'm all new to Unity.. Should I use a tiemap grid?
wel even if u guys help me solve the streching, i could change the texture design
its no big deal
did you check the docs? https://docs.unity3d.com/ScriptReference/GUILayout.VerticalScrollbar.html never worked with GUISkins, but there seems to be some more to it to have the texture being used correctly
And again, can you show the inspector when the thumb is laoded of your image component?
by inspector, do you mean what I use to load the file into a texture2d?
Inspector, of Unity, the image in your scrollbar?
im not even using unity actually
im coding and using textures
if (this.thumb == null)
{
this.thumb = www.texture;
this.thumb.Apply();
}```
So you are using Unity Coding but not using Unity? How can you see the scrollbar then? ... come on...
??
Im not using Unity program to model the scrollbar
im using namespaces and OnGUI
... I know, but you are loading a skin into the component of the scrollbar...
I'm out, got no time. If you don't wanna show the inspector, fine π got work to do.
bye ig
Hello, how can I make sure that the tiles in tilesheet, won't have these gaps between them?
just decrease the Pixel Per Unit by 1
I forgot to mention, but I fixed it by changing Filter Mode to Point (no filter)
i have this problem with spawning enemies with a button. the button parent has the code to update the destination of the DemonAlien to the transform of the ship
what i want to happen?:
i want the enemy to instantiate in scene when OnButtonPress() and start following the coordinates of the ship given by the button parent script
what is happening actually?:
when i spawn the enemy (click the button) he is in screen for one second and then goes flying away and its coordinates go mad and i dont know what to do...
(*sorry for the flood)
I didn't know Rigidbody2D.rotation existed
it looks so convenient
if you put .rotation at the end of a gameobject you directly acces to its rotation
I know, but, the reason I think it's convenient is because
Rigidbody2D's rotation is a float as opposed to a quaternion.
I expected it to be a quaternion like Rigidbody.rotation.
hey quck question, how do you make this code only accpect strings, becuase i cant covert a int to string and idk how to get it to not do that string eSelectedMove = Random.Range(0, possibleAttacks.);
wait
there might be something missing there but idk
i was fiddling with it and gave up
string eSelectedMove = Random.Range(0, possibleAttacks.Length);
thats what it is when its done
need it to be string to string
can anyone help? i have to go for a while soon
@empty garden eSelectedMove is declared as a string.
Random.Range, as you are using it, is returning an int
Where is the string value expected to be coming from ?
Are you meaning to use the Random int value as in index into a list ??
something like this ?
string eSelectedMove = possibleAttacks[Random.Range(0, possibleAttacks.Length)];
Let's have a look at the easiest and best way to make top down shooting in Unity!
Check out Jason's courses! https://game.courses/mastery-course-brackeys-bonus/?ref=21
Unite Copenhagen: https://unity.com/event/unite/2019/copenhagen
Armored Soldiers: https://bit.ly/2Zqqn9P
Warped caves: https://bit.ly/2PsOyzS
Tiny RPG Forest pack: https://bit....
so i need some advice about something im trying to do
im making a top down shooter and im partially using this tutorial since im new
in the tutorial they essentially have the sprite and just rotate it when you move the mouse, which in turn rotates the fire point on the player body, which redirects where you shoot from
which would work well except im trying to make it so that the sprite itself doesnt rotate, my game will be more isometric and the character will animate to face towards the mouse in 8 directions, basically
whereas the tutorial just rotates the character which only works if the camera perspective is completely directly overhead
so, i dont know how else to shoot where the mouse is pointing other than rotating the player to move the fire point to the proper position
how would you deal with this? im not sure how other top down games achieve this
im thinking about just making the player object rotate like in the tutorial and just have a player sprite over the invisible body and animating the sprite? does this sound like a smart solution or is there a better way?
@ornate lava sorry im back
let me show some more of what i was trying to do
string eSelectedMove = Random.Range(0, possibleAttacks.Length);
Debug.Log(possibleAttacks[eSelectedMove]);``` this should be all that is needed to know idk
and i want to randomly pick one string from here
then im trying to make it so that if lets say "cut" is the string chosen that it will then do something ele but i know how to do that
string[] possibleAttacks = { "Cut", "Poke", "Bash", "Block", "Parry", "Grapple" };
int eSelectedMoveIndex = Random.Range(0, possibleAttacks.Length);
string _attack = possibleAttacks[eSelectedMoveIndex] ;
Debug.Log($"_attack mode : {_attack}");
@empty garden Perhaps something like this ?
I have a player who can move left and right and the weapon kind of just floats infront of him. I made the weapon a child of the player. When the player turns around he flips and the weapon is supposed to float in front of him again but instead it floats behind him. What do I do to fix this?
Nvm fixed it
@frozen anvil How, ? did you multiply the child localScale X by -1 ?
@ornate lava this might work sorry for the late response. at six i have a class that can help me further i just wanted to do more so i will have more done before then
yeah the thing is ive done this in c++ three times becuase i try to make it in command line
but always dont have enough skill to do it
so im trying to see how far i get in unity
so i know the path on what to do not how to do some of it
This makes it easier to understand, perhaps
string[] possibleAttacks = {"Cut", "Poke", "Bash", "Block", "Parry", "Grapple"};
int eSelectedMoveIndex = Random.Range( 0, possibleAttacks.Length );
string _attack = possibleAttacks[eSelectedMoveIndex];
print( $"possibleAttacks.Length : {possibleAttacks.Length}" );
print( $"_grapple mode : {possibleAttacks[possibleAttacks.Length - 1]}" );
print( $"Random Index and _attack mode : {eSelectedMoveIndex } == {_attack}" );
Can someone help me? Whenever i move my arms my whole body connects weirdly to it
(first 4 secs the game loades)
@vocal ravine irl or in your game?
idk
dont you want the arms to be attached lol, dont see anything wrong with that gif
i want them to be attached but when i move them my body stars flying
the collision is turned off
So you didn't jump on purpose in that gif?
make arms rotate around a central point on shoulders to point the cursor
that looks like you are just moving them
nope
it is doing that
this may help you:https://www.youtube.com/watch?v=LNLVOjbrQj4
Let's have a look at the easiest and best way to make top down shooting in Unity!
Check out Jason's courses! https://game.courses/mastery-course-brackeys-bonus/?ref=21
Unite Copenhagen: https://unity.com/event/unite/2019/copenhagen
Armored Soldiers: https://bit.ly/2Zqqn9P
Warped caves: https://bit.ly/2PsOyzS
Tiny RPG Forest pack: https://bit....
(to rotate the arms)
ok
i recommend have a parent object and make that rotate towards the cursor with help of video
So im having this issue where my particle wont show however it does spawn can anyone help me?
so Vector2.up, Vector2.left and so on exist...is there something similar for the 4 cardinal directions of a single Euler angle?
eh, nevermind
not all that important
got the thing working I wanted this for, too
anyone good with trig willing to check my work here?
trying to calculate the distance of the ?
all known values are labelled
ping me if you have anything for me
@scenic ether Looks good to me. A simple tangent calculation. as long at that O isnt a zero lmao. Tangent is Opposite over adjacent, and you isolated the Opposite/the ? correctly. You calculated the angle right, that angle inside the triangle is pi/2-n(Theta). I think your right.
I dont se any problems with your math
O is a label, i shouldve chosen a better label haha
Yea, i figured that out when ?/O wasnt undefiened lmao

But what are you using this for? what game mechanic do you need this trigonometry for?
basically i was trying to create my own collision physics system
the diagonal line there is a wall, and the line formed by (sx, sz) and (ox,oz) is the velocity vector
i was trying to calculate the missing side to determine how much the velocity needed to be adjusted to avoid a clip
but since then i've decided on a different approach
Can somebody please help me fix my script? I have no idea what's wrong and no idea how to fix it......
Firstly you should properly configure Visual studio using the instructions pinned to #π»βcode-beginner
Then you need to provide more context about what on earth GetDebuggerDisplay is
I have no idea it was Unity who put it there as part of the default code
I have never seen Unity do that
Do I delete it then?
Yes, that attribute is not relevant
ok
You also have other basic mistakes that should be highlighted and avoided when your IDE gets configured
Visual Studio/Visual Studio Code and likewise
oh ok
My version of unity doesn't have the "Editor Attaching" checkbox. What do I do?
Ignore that step
Both misspelling/incorrect names
...
@supple vine The red squiggly underlines are pointing out the errors for you.
Thanks for pointing that out Captain Obvious
π
No need to act like this. You acted as if something was unclear, so they clarified.
I said "..." because I was embarrassed about the spelling mistake
I'm making a platformer and I want the camera to slide left or right once you've left it's view. Any idea on how to do that?
@mortal palm Look up cinemachine
Thanks, I had no idea what to search
In the package manager FYI
hello can some one help me with my code my weapon startes chnaging its rotation by its self
its a bit complicated so i want to screen share
It's probably reacting to gravity, try changing the Body Type in Rigidbody 2D from Dynamic to Kinematic
it isnt that
thats my code for the weapon https://hatebin.com/dhrfzrabqf
and that is what is happening
its caused by the flipping
only when i look down or up my weapon rotation starts changing
it doesnt know where to flip when youre not to the right or left
so its trying both
Try this:
else if ((Mathf.Abs(weapond.transform.rotation.z)) < 0.7f)
{
player.transform.localScale = new Vector2(0.8f, player.transform.localScale.y);
weapond.transform.localScale = new Vector2(1.25f, 1.25f);
}
actually, it might not fix it either
so do i do it?
Hi, yesterday i asked about how could I make a ball roll around the screen, I just wanted to share that I tried a bunch of things, but what worked best was simply using AddTorque with the rigidbody, and works very nice :D
rb.AddTorque(Input.GetAxis("Horizontal") * speed);
Here is a video of the game working
I could not find what to do here. Could you please help
Does the filename match the class name?
How so ?
It's saying that you've got this script file that doesn't have any matching class inside so Unity will not let you use it at a component.
Just look at the class name in the file and the filename. Do they match?
Exactly, letter for letter; case sensitive.
I did their names the same.
Show an image of the class name
DegiskenManager
That isn't the class name
The class name is the name of the class inside the script file.
I don't know because I just got into this job, I'm sorry.
That's the object name and the one in the assets folder is the script/file name
You need to make sure the file's name is identical to the class' name; inside the file.
is this?
how do i fix π
What're your current errors?
Check the console tab in Unity Editor.
And you've got errors in your code.
You aren't properly assigning the string a string literal. And your debug log is incorrectly used.
Should probably ask for scripting help in #π»βcode-beginner and they may point you to some tutorials on basic c# and Unity scripting.
Thank you for help me
there is an error that idk how to fix
Copyright (C) Microsoft Corporation. All rights reserved.```
Hey, is there a way to flip a child gameObject at the same time I'm flipping the parent sprite in my sprite renderer component ?
If instead of flipping the renderer you flip the transformβs x value the whole object (colliders, sprites, particles etc) will be mirrored. Is this what you want?
@still tendon Yep, I just found out I could do that, thanks
does RaycastHit.normal return a normal that points inward from the collision surface or outward?
Hello, so Iβm trying to make a game using a mega man sprite and I am trying to make it shoot but the issue I am having that the shooting animation keeps overlapping the idle animation. So the shooting animation is two short. Can anyone help me solve this problem?
In animator on transition settings you can adjust how animations are blended (timings).
I tried that and nothing happened
Than posts details / screenshots how you configured transitions and animations
okay so im waiting for my Unity to boot up right now, but I did all my animations in code, the issue im having is that my idle animation is always player when im on the ground. So I need a way to stop it from constantly playing the idle animation so It can play the shooting animation
Animator setup, you graph and transitions?
I havnt really been using the animator, when I tried nothing happened
Thats the problem, you need to setup transitions and blending between animations
Yeah but I have other animations working off of pure code
I'm fairly certain that I need condition that checks if I am playing the shooting animation, I just dont know how to write that
It's much easier to achieve with animator. For code writing: try, fail, repeat
Probably, but Ive been going off of this tutorial https://youtu.be/44djqUTg2Sg
βΊ Easily Make Platfomers in Unity - http://u3d.as/2eYeβ
βββΊ Easily Make Car Games in Unity - http://u3d.as/1HFX
Wishlist my game Blood And Mead on Steam!:
https://store.steampowered.com/app/1081830/Blood_And_Mead/
How I nearly destroyed my game, but Nintendo wisdom saved it:
https://www.youtube.com/watch?v=a4M-21AMiQE
In this game dev tutori...
So I dont know how I would transition to that
Do some animator tutorials, learn, refactor.
Alright
I'm trying to use Physics2D.OverlapCircle
but I'm having trouble setting a layer filter to a contact filter object
does anyone have top-down code
I used
ContactFilter2D filter = new ContactFilter2D();
filter.SetLayerMask(LayerMask.GetMask("Enemy"));
but it doesn't work
hi
do you have top down code on hand
no
might you know any videos
brackeys
Hello I'm trying to make a toggle that loops a slider over a period of time.
If the toggle is on -> slider goes up -> if slider reaches max then it starts over and loops.
Any help would be appreciated π
Check dotween asset, it's easiet way to achieve this
So, im going to have to paste a large chunk of my code in here, cuz there are several posibilities of what could be wrong with my code. and i dont really know whats happening. I also will share a link to a streamable of the video of whats going wrong.
not too large, but a chunk
Just send your code via a service like hatebin
I tried that earlier but im confused on those. like i dont get it it wont give me a link to paste, only the code.
You just click save
ok nvm im retarded
https://paste.myst.rs/vrhxa0vi
This script is put onto my camera, and i have properly assigned the object Character to the sprite i was controlling by drag and drop. I am trying to have the camera follow you on the y axis only when you get close to the edge of the screen. it works for when i drop down, but not when i go up. It teleports off somewhere, i do not understand it.
a powerful website for storing and sharing text and code snippets. completely free and open source.
i dont know why. and that - or minus with the Character.position.y + (Size-1) on line38 i have changed back and forth. It should be -.
huh.
i couldve sword that was z. Thanks
now to implement it slowly returning to the right y position once he is not in the air.
loop time lmao
how can I change the depth of a bone from code?
Im trying to have a camera decelleerate as it is panning to a specific postion depending on how far away it is. Do i have to use rigidbody2d? is that going to screw with my current camera system where i just set the position to where i want it?
how would i even go about it doing that? for loops?
i would need some way of approximating that im close enough to a position and then teleporting to it.
@compact blade you could use rigidbody2d but you could also do that just by modifying the transform
i'd start by writing out an equation that relates the variables you care about: the position of the camera, the position of the object you're moving towards, and the speed you're moving
once you've got that, you can set the position of the camera (its transform.position) to the result of that equation in Update() (making sure to multiply by Time.deltaTime, which is the amount of time since the last frame)
i don't think you'll need loops
Hey I am new to unity and C# in general and i was wondering how to make a death zone in my 2d game.
@fervent cosmos what's a death zone?
a place where a player will die and then respawn
like in a platformer game where a player goes off the screen it will respawn the player at the beginning
high level, you would use make an empty gameobject and move it to where you want the respawn point to be
then, when the player "dies", set their position to that gameobject's position using a script
ok thanks
if the player dies by going out of bounds, you'll want to look into colliders
ok
Ahh dangit the one this that i didnt want to break isnt working right.
thing*
my isGrounded Check was not coded by me, but by a friend and i dont understand it. it doesnt properly detect im grounded if im at the very edge of a collisionbox.
Is it possible that i could send a link to the pastebin of it and someone could explain it to me in rough terms?
i think it might be something i need to understand lmao
if so, link is this: https://paste.myst.rs/5zvymzo4
a powerful website for storing and sharing text and code snippets. completely free and open source.
Got a pretty interesting problem to solve.
I have a small sprite object that takes up maybe ~10-15% of the whole screen, situated automatically to be in the top-left based on camera position. Like this:
What I want to do is
to not only clone that square sprite until it fills up the entire screen (it's okay if the sprite goes past the right-side or bottom-side edges, but if we clone it after that, it's redundant)
BUT also find a way to move this entire new sprite "mass" a la a scrolling background (think Animal Crossing menu background.)
My idea would be that I'd make all the clones children of the parent... But then I don't have a good way to gauge the size of the entire thing.
are you talking about anchors? @barren lark
so are you using anchor to put sprite on top-left??
if not me wrong anchor makes it very easy
Oh, well I've already taken care of that part.
I want it to fill up the whole screen, and then move diagonally.
OoO
kind of animation
size according to screen is easy
obj.transform.scale = new Vector2(Screen.width, Screen.height);
may people use transform.localScale
@barren lark
and then you can use for bottom left
obj.transform.position = new Vector2(Screen.width - Screen.width, Screen.height - Screen.height); // means 0 lol. I am fooling you π€£π€£π€£
@barren lark
Ah, that's still not one I'm talking about. I'm having dinner now, please don't mention me again. But I appreciate your effort to help nonetheless.
oh ok
What I mean is that...
All these cubes are clones of the shaded cube, therefore making a tile pattern.
I need to figure out how to dynamically "wrap" them as the entire group of tiles moves horizontally, vertically, or a mix of both.
I also need to figure out how to arrange them on-the-fly.
somebody pls help me
Configure Visual Studio properly so it helps you not make mistakes and highlights your errors. Instructions are pinned to #π»βcode-beginner
Also, sounds like you haven't declared shouldDie, and timeBeforeDestroy is not a method. The errors seem pretty clear about it all
I've got an odd condition going on with RigidBody2D. I have a simple platform controller which works and stops the controller from moving with both an if check and a clamp. However.... when it stops moving, this happens: https://i.gyazo.com/8238a73f860214d8085ec81aca30f5ee.mp4
Even though the platform should be stopped, it continues to act as though forces are applied even when it's hit the range limitation: https://pastebin.com/6fsrjqDK
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.
Essentially.. the "physical" object is responding to the clamp, but the rigidbody itself... isn't?
Does anyone know a easy teleportation code for my 2d game. I want the player to teleport to a place when a game object is touched
void OnCollisionEnter2D(Collision2D other)
{
if(other.gameObject.CompareTag("Player"))
{
player.transform.position = newTransformGameObject.position;
}
}```
ok thanks
@meager mural when i run that code it give me 2 errors. 1. The name 'player' does not exist in the current context. 2. The name 'newTransformGameObject' doesn't exist in current context.
This is the code
Yes. Because is psuedo
Substitute those variable names for what you use / are going to use
Hey, how do you pixelate only one object in 2d ?
You cane use pixelate shader on this object
Isn't there a way to do it via render texture and camera layers ?
I don't know, try googling it
so this thing i need help on might be better to do later but ill ask anyway to see if it should. basically i need to make an index, or list, or idk what to call it, of all the moves or attacks in my game, what they do, how they affect the player or the enemy, how much damage it does, and a value stored in them to seperate them into six categorizes
so let me explain
there are six move types in my game
slash, pierce blunt, block , parry, grapple
one move might have the slash pre-fix on it
another pierce
ive never been able to figure out how to do this but its important for my code
i might be able to figure it out over time, but i wanted to know if i can get help here
You can use scriptable objects to store this configuration, or do you ask for something else?
im not really sure
i mean the player and the enemy might use these, or only the player, or only the enemy
kinda like a big dictonary of moves
and it needs to do everythng the attack does
like if its a bleed effect
i need it to explain in the code, how bleeding works
in the game
if the target attacks with a bleed on them they take damage
that might be hard to get in at first but at least making the list of moves needs to start
poison would work the opposite
if the target defends they take damage
even if this doesnt do anything rn i should at least list it and comment what it would do
Looks like you need to design class structure that holds all this information and the rest of the code can use it. As root object you can store it in Scriptable Objects.
one second i forgot i needed to open unity
ok
when you say scriptable objects im reading it on the unity site what do you mean and how do "inherit" my script from the scripable object class
idk sorry very new to unity
is it just something you write in your normal c# script
or a special file you make
yes and yes, special C# class that can be instantiated in editor as asset
ok so just make a c# script and call it like moveIndex? then instantiated it in my class how? or wait i think your saying its different from a regualr c# script where is it found?
Ok, best would be to follow some SO tutorial. Plenty of those.
yeah i might read up on it for a bit sorry
ill be back if and when i figure it out quicklu enouigh
ok so scriptable objects cant be attached to game objects which may or may not be a problem idk yet
I mean you could make a new scriptable object and child it to the object
If you treat them purely as definitions what to do and they do not have any state than it's safe and fine to attach same SO instance do many objects.
i mean yeah eventually there will be buttons and the player pressing on them to trigger the move's abilities but i think you can still use scripable objects still
Yes, actual skill state can be stored in MB attached to entity that trigger it.
ok whats annoying me is i cant find the create scriptable object button in the editor
thats what meant before
and i googled it a bit and its not where it should be
when i look in the same place the others did
i saw it was right under legacy but its not there for me
you just create C# class and extends ScriptableObject base class
oh
other people were showing its something you can create in the editor
ok i get it now
looked up so tutorial for it a bit
lemmie just get change the monobheavoir thing
to the sciptable object
ok im good and ready now i think
sorry
so i dont think i would use a separate function for each thing right? maybe a dictionary or something similar? when i tried to make this in Python dictionaries almost worked for what i needed them to do but i couldnt organize the dictionary into catergoires i think and thats when i gave up on python
i mean i could have made just 6 different dictionaries for pyhton looking back
but thats in the past i want to try to get it in unity to work
i dont know how i would orgainze all the moves in this class.
@deep dove you there? sorry for the ping
But you make SO that holds commond definition for example you can name it Skill
add all things you need to configure differently between skill, and create instance for each skill in editor
If you need some really specific things for some skills you can create new class and expend base Skill
Or you can go for some composite approach design but this is usually harder and requires better class design experience.
I think I also saw some yotube tutorial exactly that someone creates some sample skill hierarchy based on SOs
i mean i dont know how it would get really specific some might inflict a damage over time, or activate two different move types
so like a parry and a block in one move
maybe link it if you think it could help me?
also im looking at some sites i dont know what youmean by common defntion
I think this is more design problem than specific unity problem. Like you need to design you class structure to support all cases. This is usally hard, easier is to start with something small and refactor to more complex design.
hmmm ok i might wait on this then
In this recorded live training session from August 2016, we create a flexible player ability system which includes player abilities with cool downs, similar to those seen in MOBA or MMO games. The approach uses scriptable objects and is designed to allow game designers to create multiple variations of an ability and swap between them easily.
i have a class on unity on tuesday so i might wait to ask there
i might come back later for the other thing i might need help with.
Is it possible to hack the particle system into allowing the Experimental 2d Lights ?
With hacking you mean using a 2D material/Shader that reacts to the lights, I guess
No, the particle system wants a normal light in in its "public variable slot" I'd like to try a 2d light. These lights spawn with the particles and inherit some things like intensity if i recall correct.
create 3d light, but also attach 2d light to the same object and use script to copy parameters you need form 3d light to 2d light?
use: while (transform.position - target < someThreshold)
Floats that are part of the vector can't really compared in this way
rounding etc. check this https://docs.unity3d.com/ScriptReference/Mathf.Approximately.html
just assign final position when you leave loop, but don't compare vectors using !=
You never leave the loop because of imprecise float comparison, same exact position still may not be exact in the terms of how float comparison works on CPU
it doesn't matter why it works for some values
so ive done this at least three times in command line c++ but im interested in maybe doing it a simpler way in unity
so the final part of the game that determines how combat works is a rock paper scissors type of code but with three six different ways to win
slash beats all defensive moves expect block, if you get blocked you take counter attack damage. if two of the same moves hit each other nothing happens (for now) and if two different attacks get each other then you both take damage. this works for all moves in the game
i did a very long way of doing in before
can unity help me do it quicker and simplier?
any logic like this mean coding and its probably the same way you did before, except c# syntax probably easier than c++, but yeah in general its gonna be the same thing
From my experience, the more complex the logic is, the shorter it can be in C++ due to said complexity increasing the amount of opportunities to use features C++ has that C# doesn't.
pointer, template and variadic stuff, especially
Simpler doesn't always mean shorter
Simpler can mean more verbosity and code duplication
what i mean is that is their a quicker more compressed way to do this code than what im thinking of which is a big if else statement
i think i did that
yeah
i did
or maybe it was case
either way i did a huge thing that was like if the player slashmove bool is true and the enemy block bool is true then the enemy wins
and i did that for like everything
and the thing is i have to set it up in a way that allows for the flexible nature of different attack moves
because there could be 50 different slash moves but all slash moves are blocked by a block
and i get that it migth not be shorter but it needs to be flexible and be functional with future code
i can always change it but i want it so its here not set up not rigid
i mean the bool of the code might not make it matter wheater its slash attack a or b
becuase it checks for the bool
not what spefic attack its comming from
Weigh the value of the attack and use that to evaluate rather than comparing the different types of attacks directly. Then again, it'd be dependent on your design and what's necessary.
That way, you'd have a much more condensed logic for the comparison.
i mean maybe i wouldnt know, basically the index of moves in the game that i wanted to do eariler will have a value attached with it. lets say slash. if the player chooses that attack it will make a bool go off, that bool will be compared to the other enemies bool then the combat outcome will happen
that was my idea
but i wouldnt know how to get yours to work
At the minor expense of determine or managing the weigh of the attack; ultimately depends on your design but this would definitely introduce flexibility.
the attack values dont exist yet only the attack types
ok
i mean i wouldnt know how to do what you are saying though. thats the thing
so like rn the player can choose to do a slash attack and thats it, later they can choose what kind of slash attack to do
like the list of known moves
So let us say Slash-88 is worth 7 points and Fireball-63 is worth 4 points. You'd just have a comparison of if attack one's value was less than or greater than attack two's.
I've got to go but your question is probably more preferable in #archived-game-design or #π»βunity-talk than here; this channel is more for coding/scripting questions rather than design questions.
Good luck.
wait but how would that work, this is rock paper scissors the rpg, it would get difficult comparing numbers right? why not... i forget what a single letter string iscalled but that, so A beats B and B beats C?
well im designing a script tho
i know what design to do
i dont know how to script it
for the best way possible
becuase i can do a simple/long if else statment for this
im looking for an alterative
id start by creating a project and beginning the coding in c# first ;p
i did
this is like the last step i need to code in the other stuff ive always run into problems with command line C++
You've got to find the pattern in evaluating your attacks. Then you'll have a universal and flexible method to handle comparisons.
i have buttons and everything
yeah exactly
i just dont know if my big if else statment will do that or if a different way ive never thought will
ive used characters 'a' like that to do comparisons before
but that got a little too messy
and confusing
You can usually condense repetitive code; which I suggested.
yeah this is super repetive
But it would be dependent on your strength in design patterns.
i would love a better way to not have it be so repeatiative
If you cannot determine find a solution, you may just have to stick with it or ask in #archived-game-design .
yeah and thats where i probably fall off i can design ideas well but im an amature coder
ok ill check game design
You're the designer, so it's ultimately up to you but I can tell you your big (hopefully it's big enough to warrant optimization else you're wasting time with premature optimization) if-statement of attacks is likely condensable. You just need to make and completely understand the rules of your game.
i mean ok lets think about it i have 6 moves
three attack three defenses
there are three things to happen to those moves
they can damage, be blocked get damage and damagaed, or get into a tie
four
actually
so i have to check im bad at math sometimes
3 times 3 times four? or is it 3 times 3 times 3 times four im bad at this
Depending on design, you could just simply have a class of attacks and overload what occurs depending on the other type π€·ββοΈ; open ended.
yeah that might work too but i have no idea what you just said
its just a simple comparison
Hey everyone, have a little problem that i am unaware of how to fix. My camera follows the bullet i shoot and my bullets are invisible.
The only component where camera is mentioned is on my player asset where i use it to rotate my player to cursor position.
The character movement code i made;
public float speed = 10f;
private Rigidbody2D rb;
public Camera cam;
Vector2 mousePos;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector2 movement = new Vector2(moveHorizontal, moveVertical);
rb.AddForce(movement * speed);
mousePos= cam.ScreenToWorldPoint(Input.mousePosition);
Vector2 lookDir = mousePos - rb.position;
float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg + 90f;
rb.rotation = angle;
}```
If it ain't broken, don't fix it is my only advise then.
again ive done it before in C++
the thing is idk if it will be broken going forward
becuase ive never gotten farther than this in C++ command line
I've program in c++ for 15 years but it's not relevant to the games design.
If you had the logic block in your c++ application, you'll have it here too.
If you solved it there, it wouldn't have been a problem here.
no its not that
i just didnt know how to proceed after this, also though
if it is comparing bools
the way i thought of it
how would it reference back to the attack it got the bool from
best way is to start coding it and the logic will come eventually
Brain storm Preferably in #archived-game-design (open ended)
how does my combatHandler know that the slashattack bool was triggered from Fire Swipe, a fire move
yeah
ill go there for now
The more you code/implement other designs such as A* (don't shoot yourself), the better your algorithms will get.
i mean i get more direct help on tuseday
i wanted to see how far i could get without it rn

Well my camera follows my bullet whenever i shoot one
that is the problem?
yes
π
Wellp lets make it one
Like my cam has no component
no script is touching camera
but it follows it
i am gonna restart the project i screwed something i cant find
the cam get attached to the bullet somehow
what is the bullet script looking like, or the way you instantiate the bullet?
its pretty simple actually void Fire(){ Instantiate(bulletPrefab, firePoint.position, firePoint.rotation); }
firepoint is an empty asset
bullet prefab is a prefab i drag to the component inspection
the only place where i mentioned camera is here mousePos= cam.ScreenToWorldPoint(Input.mousePosition); Vector2 lookDir = mousePos - rb.position; float angle = Mathf.Atan2(lookDir.y, lookDir.x) * Mathf.Rad2Deg + 90f; rb.rotation = angle;
{
if(Input.GetButtonDown("Fire1")){
Fire();
}
}```
simples shit you can find
yeah that doesnt move it
i like simple code i can understand
people suggest me using premade character movement scripts and stuff but i prefere making it myself
yeah
{
rb2D = GetComponent<Rigidbody2D>();
rb2D.velocity = transform.up * speed;
}
}```
thats all
they often come with behavior you might not like and end up having to understand their whole code to change stuff
so yeah its better to make ur
unless its something big
yeah even attaching to the assets is hard when you copy a 100 line script
I think i am gonna open another project
i dont see why the cam follow ur bullet
if i could get a penny each time i opened a new project
cant think of anything
i just sent you the 3 scripts in my game π