for those who didn't get the head rotation code: I'll give a brief explanation 1. direction = target.position - transform.position; basic vector math whenever you want a direction vector between 2 points, you subtract them. 2. float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg basically calculation angle like in a unit circle. now you might ask, why is it y and x and not x and y because coordinates will be (cos, sin) it's because unity's angle system as 90 degrees of offset, and sin and cos also have the same, so we exchange them. It will also work if you did x and y and subtracted 90 and Mathf.Rad2Deg does what it says. 3. Quaternion.rotation calculates rotation on the z-axis(Vector3.forward) based on the angle we provide. 4. we use the calculated rotation to rotate the head and that's it. hope you got it. :D you can watch Sebastian Lague's video on trignometry for more details.
I asked about this in the comments for your recent gamejam entry video, maybe you saw it. Thanks for making this video, these kind of things are great to learn about! :)
I can't believe you did a tutorial about this. I asked you how you created this in your BTP game and voila' .. a whole tutorial about this :) This is awesome! Thanks for your fantastic videos!
Absolutely loved this inspiring tutorial, especially because I am a nerd for procedural animation, and what it does to open up young minds to math and science they learn in school! Thank you...
Your tutorials have helped me out with my own game, Stop the Saturnians, so much! Thank you! This one in particular taught me how to build the Centipede enemy ships. Thanks again, really appreciate what you do :)
Can't thank you enough for your tutorial. These type of creatures I hadn't ever thought of making it, because of the complexity my brain created. Thank you very much!
At 2:37 if your character staying still in the middle of the screen is likely due to the "Vector2.MoveTowards" function not being used correctly. This function requires a starting position, a target position, and a maximum distance to move. In his code, he using the "transform.position" as both the starting and target position, which means the object will never move. To fix this simple just change the code to: public class RotateToTarget : MonoBehaviour { public float rotationSpeed; private Vector2 direction; public float moveSpeed; void Update() { direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position; float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, rotationSpeed * Time.deltaTime); Vector2 currentPosition = transform.position; Vector2 targetPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = Vector2.MoveTowards(currentPosition, targetPosition, moveSpeed * Time.deltaTime); } }
Quick Tip: To simple rotate transform you can use transform.right = -direction; transform.right = direction; transform.up= direction; or transform.up= -direction, depending on which direction you have a sprite
Hey :) I've released an online multiplayer course on Udemy with my brother! People seem to really like it, and it's a great financial support for us, so consider learning from it. There's also a 30 day money back guarantee, so if you don't like the teaching style, you can get a refund. Cheers!
@@Blackthornprod I just bought your Game dev/art and 2d game courses. I hope to learn as much as possible. Also keep up the good work. Watched quite a few of your UA-cam videos first to judge you xD. I can see me spending a lot of hours watching your tutorials. Cheers.
this is exactly what I needed! Im making a platformer and I want the main character to have a nice looking scarf that follows him, and I think this will look perfect. there's something ethereal about the style of my game so I think the lack of gravity will only add to that. edit - I put it together and *I love it so much!*
Hey, how do you stop your scarf's length from getting increased when your player moves. For me when my player moves his hair length increases on of its own then the original size when player is standing.
Amazing tutorial! How would someone add some kind of gravity effect in case we want something similar to a tail or hair that looks naturally influenced by gravity?
My solution was to make a new float variable called 'Gravity' and set it to something like 0.5, then for the second parameter of Vector3.SmoothDamp I would put new Vector3(segmentPoses[i - 1].x, segmentPoses[i - 1].y - gravity)
I really love the effects and flow of these creatures with long tails or wings, so smooth and beautiful, how I would love a game without obstacles , just a fun discovery of beautiful movement art like yours and music to go with a fabulous world created, like an animated story , what do you think NOA? 😉
This video was amazing! I do want to point out though, that the script requires the ResetPos() function to work correctly. In your example, the character was placed at Vector3(0,0,0) in the world, so it worked fine, but it is a problem if the character is placed anywhere else. This is because the first point is placed at the character's position, but all 29 other points show up at Vector3(0,0,0). When the game starts, the tail will be stretched all the way to the center of the world and then retract to the character. Running ResetPos() in Start() works great to fix this :)
Hey if you see this could you give me some insight, I maybe am not far enough in the video to have seen him implement the resetPos() yet Thanks in advance!
Alright, let's do this Noah! Thanks for this, 🥰. Will be using this in my game. Love your art style, will surely check out other game Devs you mentioned. ❤️
Great tutorial. Thank you. But I am shocked and said "Oh my god! I love those characters" at 8:48 . He seems to be nailing the style. When can we play that?
Im trying to figure out how to make it so the tip of the tentacle can attack things. Almost like an IK where I can have a target that pushes toward something. Let me know if yall have any ideas :)
I appreciate the video and it helped me figure out how to create a squid. The video is a little sloppy and doesn't show some code on screen. Eventually figured it out. In case someone stumbles on this like I did, here's my code for the first part: using System.Collections; using System.Collections.Generic; using UnityEngine; public class SquidTentacle : MonoBehaviour { public int length; public LineRenderer lineRend; public Vector3[] segmentPoses; private Vector3[] segmentV; public Transform targetDir; public float targetDist; public float smoothSpeed; public float trailSpeed; private void Start() { length = 10; targetDist = 0.1f; smoothSpeed = 0.04f; trailSpeed = 350f; lineRend.positionCount = length; segmentPoses = new Vector3[length]; segmentV = new Vector3[length]; } private void Update() { segmentPoses[0] = targetDir.position; for (int i = 1; i < segmentPoses.Length; i++) { segmentPoses[i] = Vector3.SmoothDamp(segmentPoses[i], segmentPoses[i - 1] + targetDir.right * targetDist, ref segmentV[i], smoothSpeed + i / trailSpeed); } lineRend.SetPositions(segmentPoses); } }
@@geniusapple6471 lol. Actually I am also learning game dev on platforms other than scratch (like on Godot - but sometimes the these great people give during unity or tutorials of any other game engines, gets useful universally.)
I tried doing each steps he did. But didn't work for me. At 6:25 why line renderer not showing in game view ? Did you change some extra settings? Thanks anyway ! I will be able to figure all out in few days because of your script as I just started undertsanding C# properly.
How do you do this with AI? That fish creature inspires me to make an aquarium style game and I'd like to know how to make it swim around on its own instead of following the mouse cursor. Also how would I move it with a joystick for controllers and mobile?
You would simply need to create a patrol script, and have the head rotate to face the patrol point. For controllers, same thing, just make a classic joystick script, and have it rotate to match the joystick movement. The tail will follow behind :) (for gamepads I recommend Rewired, awesome asset pack that makes the whole input system easy!)
Any thoughts on how to make something that wiggles consistently, but stays about the same length. I've tried a few things to make this but always end up with it either being too rigid and not really wiggling the whole length of the line, or it will wiggle nicely while holding still, but then it stretches out behind the creature when it moves.
@@seahood_ , kind of. I did a lot of tweaking of the numbers and it worked close to how I wanted. Ultimately I ended up going a different direction anyway.
I know its been 2 years, but how would you go about taking it a step further to simulate like a real life tail that sorta flops around like the rainworld slugcat tail?
I really try to recreate the tail of the fox in a character and I can't do it T_T, it gets longer all the time and if I manage to stop it from getting longer it doesn't move naturally. Thanks for the video!
I love this tutorial! but i have a very big doubt... does anyone knows how to make those wings on min 12:18?? i'm not so good at coding so i could't figure it out, i'd aprecciate if someone knows how i could do something similar. Cheers!
hi, love your content! may I ask one question: is there anyway I can make a tile- base plant ( seaweed for example) that apply this procedural animation and can be add or remove length? Thanks in advance
Thanks :) Unfortunately Udemy doesn't offer a solution for making course bundles. Perhaps in the future we'll make our own website for students to purchase our courses, and offer discounts. But at the moment we don't have much control over that.
Really nice effect, dude :0
Que haces aqui? ._.
I absolutely love procedural animation, it makes games look so much more interactive and real
I love your art style, I’m surprised how well the smooth, blurred backgrounds work so well with the crisp cartoony art.
for those who didn't get the head rotation code:
I'll give a brief explanation
1. direction = target.position - transform.position;
basic vector math whenever you want a direction vector between 2 points, you subtract them.
2. float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg
basically calculation angle like in a unit circle. now you might ask, why is it y and x and not x and y because coordinates will be (cos, sin)
it's because unity's angle system as 90 degrees of offset, and sin and cos also have the same, so we exchange them.
It will also work if you did x and y and subtracted 90 and Mathf.Rad2Deg does what it says.
3. Quaternion.rotation calculates rotation on the z-axis(Vector3.forward) based on the angle we provide.
4. we use the calculated rotation to rotate the head and that's it.
hope you got it. :D
you can watch Sebastian Lague's video on trignometry for more details.
hey i tried to do the target how do i set it to a object
I asked about this in the comments for your recent gamejam entry video, maybe you saw it. Thanks for making this video, these kind of things are great to learn about! :)
Same :)
Wow this is exactly what I was looking for!!! Thanks a lot 😁
Hey i know you
@@cutecandygames1874 ello :D
I can't believe you did a tutorial about this. I asked you how you created this in your BTP game and voila' .. a whole tutorial about this :) This is awesome! Thanks for your fantastic videos!
This is so amazing! I always adored these smooth juicy Trails, Thank you so much for sharing this amazing tutorial noa and owen!
I LIKE THAT TITLE! Thanks for this tutorial ,it's really appreciated!
Absolutely loved this inspiring tutorial, especially because I am a nerd for procedural animation, and what it does to open up young minds to math and science they learn in school! Thank you...
8:48 OMG I KNEW THAT WAS KEKE AS SOON AS I SAW IT. Also i need this for my project soon so thats awesome that this vid happened to come out
Dang this is so cool! I'm gonna try this in my current devlog project, thanks for sharing this :D
Your tutorials have helped me out with my own game, Stop the Saturnians, so much! Thank you! This one in particular taught me how to build the Centipede enemy ships. Thanks again, really appreciate what you do :)
Can't thank you enough for your tutorial. These type of creatures I hadn't ever thought of making it, because of the complexity my brain created.
Thank you very much!
Dude this video is a life saver. I was trying to get a worm enemy in my game right for days now and this is just perfect!
Thank you! Gonna use this to animate ropes in the wind for my 2D metroidvania! I was animating all of then by hand - think about time consuming….
Perfect timing, exactly what I needed right now, thanks!
BlackThornProd you are a god
Your art is great and there is nothing to hate
Your the best keep up the good work
At 2:37 if your character staying still in the middle of the screen is likely due to the "Vector2.MoveTowards" function not being used correctly. This function requires a starting position, a target position, and a maximum distance to move. In his code, he using the "transform.position" as both the starting and target position, which means the object will never move. To fix this simple just change the code to:
public class RotateToTarget : MonoBehaviour
{
public float rotationSpeed;
private Vector2 direction;
public float moveSpeed;
void Update() {
direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, rotationSpeed * Time.deltaTime);
Vector2 currentPosition = transform.position;
Vector2 targetPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.position = Vector2.MoveTowards(currentPosition, targetPosition, moveSpeed * Time.deltaTime);
}
}
As always, super fun, super informative and super easy to understand. May the Lord bless you always.
You are back to tutorials I like that
What a great use of the Line Renderer. Nice one dude
How would one go about procedurally animating the clothes like the ones on the character from 0:34 to 0:37?
This is going into my playlist of Very Helpful Gamedev Stuff
Quick Tip: To simple rotate transform you can use transform.right = -direction; transform.right = direction; transform.up= direction; or transform.up= -direction, depending on which direction you have a sprite
Hi, when are you going to release the multiplayer tutorial? I love your videos btw.
Hey :) I've released an online multiplayer course on Udemy with my brother! People seem to really like it, and it's a great financial support for us, so consider learning from it. There's also a 30 day money back guarantee, so if you don't like the teaching style, you can get a refund. Cheers!
@@Blackthornprod I just bought your Game dev/art and 2d game courses. I hope to learn as much as possible. Also keep up the good work. Watched quite a few of your UA-cam videos first to judge you xD. I can see me spending a lot of hours watching your tutorials. Cheers.
Why is everyone saying "Chears" at the end
@@rendered3090 You spelt cheers wrong. Cheers
Welcome back tutorials.......
Thank you. Powerful examples inspired me to use this way instead of animation keys.
The secret to good platformers is hair physics. (cough cough Celeste cough cough)
there's so much coughing here that I believe perhaps you should go and get COVID tested
It's just the good gaming chair
Yeah i was actually curious how to code that in unity
@@JovsValorant covid?
@@milanstevic8424 are you ok bro?
Super cool Noa! Now I just need to figure out what to use this for in our 2D world 😀
This was super fun to make! Thank you blackthornprod and Owen for sharing :)
Finally some quality tutorial :) Good job !
Rotation Code at 1:38:
private Vector2 direction;
public float rotationSpeed;
void Update(){
direction = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, rotationSpeed * Time.deltaTime);
}
Dude who made it THANK YOU!!!!
everyone say it with me... thanks owen senior and noa! it looks great
This is awesome! I love doing procedural animations on gamemaker, so your video made me super exited to try it on unity!
Amazing effects. Is it possible to have mesh/rigidbody effects on these trails? That will allow them to have colliders and give/take damage....
awesome stuff, Owen and Blackthornprod. Would love to see tutorial for 3D effect!
this is exactly what I needed! Im making a platformer and I want the main character to have a nice looking scarf that follows him, and I think this will look perfect. there's something ethereal about the style of my game so I think the lack of gravity will only add to that.
edit - I put it together and *I love it so much!*
Hey, how do you stop your scarf's length from getting increased when your player moves. For me when my player moves his hair length increases on of its own then the original size when player is standing.
I'm a Man of Culture and I have seen Enough Tentacles to know where this is going ✨
n O
Vraiment les meilleur Tutorial. Merci :)
The best Tutorials man I LOVE YOU
Amazing tutorial! How would someone add some kind of gravity effect in case we want something similar to a tail or hair that looks naturally influenced by gravity?
My solution was to make a new float variable called 'Gravity' and set it to something like 0.5, then for the second parameter of Vector3.SmoothDamp I would put new Vector3(segmentPoses[i - 1].x, segmentPoses[i - 1].y - gravity)
@@fragrantupholstery2779 Oh wow thank you!
Thank you so much, made my day
kind of a long shot but did you guys get this working?
Really nice effect. Ive been using the built in particle system's trail module for basic trails at the moment
Black On The Block! Great as usual! Black is the new Brackey!
Main Code at 6:15:
public int length;
public LineRenderer lineRend;
public Vector3[] segmentPoses;
private Vector3[] segmentV;
public Transform targetDir;
public float targetDist;
public float smoothSpeed = 5f;
private void Start()
{
lineRend.positionCount = length;
segmentPoses = new Vector3[length];
segmentV = new Vector3[length];
}
private void Update()
{
segmentPoses[0] = targetDir.position;
for (int i = 1; i < segmentPoses.Length; i++)
{
segmentPoses[i] = Vector3.SmoothDamp(segmentPoses[i], segmentPoses[i - 1] + targetDir.right * targetDist, ref segmentV[i], smoothSpeed);
}
lineRend.SetPositions(segmentPoses);
}
I really love the effects and flow of these creatures with long tails or wings, so smooth and beautiful, how I would love a game without obstacles , just a fun discovery of beautiful movement art like yours and music to go with a fabulous world created, like an animated story , what do you think NOA? 😉
This video was amazing! I do want to point out though, that the script requires the ResetPos() function to work correctly. In your example, the character was placed at Vector3(0,0,0) in the world, so it worked fine, but it is a problem if the character is placed anywhere else. This is because the first point is placed at the character's position, but all 29 other points show up at Vector3(0,0,0). When the game starts, the tail will be stretched all the way to the center of the world and then retract to the character. Running ResetPos() in Start() works great to fix this :)
Hey if you see this could you give me some insight, I maybe am not far enough in the video to have seen him implement the resetPos() yet
Thanks in advance!
@@DonTouch RestPos() shows up briefly at 12:32
@@99bosses22 Thanks so much! 🤘
It’s been a long time since I watched blackthornprod :)
Welcome back :)!
Amazing! Thank you so much for uploading! ;)
definitely saving this one for later
I was looking for this, thank you so much man
Another good tutorial as always!
The wiggle does not work when I use the tentacle two script I want the wiggle to happen and also to not stretch. How can I do that ?
is it possible to add collision to the tentacle/hair/ whatever? Would you just have to add like a rigid body to it or something?
Yeah i managed to do it.
How, i cant seem to figure it out@@pelodofonseca6106
Alright, let's do this Noah! Thanks for this, 🥰. Will be using this in my game. Love your art style, will surely check out other game Devs you mentioned. ❤️
That’s very cool thanks for sharing and shoutout to Owen)
Great tutorial. Thank you.
But I am shocked and said "Oh my god! I love those characters" at 8:48 . He seems to be nailing the style. When can we play that?
Great, thanks, just what I was looking for.
I am gonna add this technique to my sprite mask and modify it a bit..... thanks for the tutorial btw
Now this is *something* else
Very beautiful effects.
Awesome, thank you! You seem to always notice where there is a tutorial gap on youtube :)
Im trying to figure out how to make it so the tip of the tentacle can attack things. Almost like an IK where I can have a target that pushes toward something. Let me know if yall have any ideas :)
Imagine now using a All In 1 Sprite Shader material on top of this awesome stuff 😎🔥
Oh YES man. Will be merging the two in future projects!
@@Blackthornprod Hell yeah, some sort of spooky misty trail or something like that. Although I'm sure you'll think something better :D
I appreciate the video and it helped me figure out how to create a squid. The video is a little sloppy and doesn't show some code on screen. Eventually figured it out. In case someone stumbles on this like I did, here's my code for the first part:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SquidTentacle : MonoBehaviour
{
public int length;
public LineRenderer lineRend;
public Vector3[] segmentPoses;
private Vector3[] segmentV;
public Transform targetDir;
public float targetDist;
public float smoothSpeed;
public float trailSpeed;
private void Start()
{
length = 10;
targetDist = 0.1f;
smoothSpeed = 0.04f;
trailSpeed = 350f;
lineRend.positionCount = length;
segmentPoses = new Vector3[length];
segmentV = new Vector3[length];
}
private void Update()
{
segmentPoses[0] = targetDir.position;
for (int i = 1; i < segmentPoses.Length; i++)
{
segmentPoses[i] = Vector3.SmoothDamp(segmentPoses[i], segmentPoses[i - 1] + targetDir.right * targetDist, ref segmentV[i], smoothSpeed + i / trailSpeed);
}
lineRend.SetPositions(segmentPoses);
}
}
Some really nice uses for the line renderer, now I just need to learn to make art.
Gotta save this for later
Hey great tutorial noa !👍
Nice video! I´ll 100% use this for one of my games
_Wait_ , how'd you read my mind?
Just what I wanted...
But how?
Noa's a *psychic* .
You are here!????
@@coderarcher7122 Obviously xD
@@geniusapple6471 lol. Actually I am also learning game dev on platforms other than scratch (like on Godot - but sometimes the these great people give during unity or tutorials of any other game engines, gets useful universally.)
Haha nice dude. But i recommend Unity over Godot, cause godot is more 2d based
If only I had seen this earlier. This looks awesome :)
i know in kinda late, but would it be possible to add a collision to the tail, i couldnt find any solution because it is moving by transform.position
how exactly did you get this wiggle bone effect on your wings at 12:17
Awesome work!
I tried doing each steps he did. But didn't work for me. At 6:25 why line renderer not showing in game view ?
Did you change some extra settings?
Thanks anyway ! I will be able to figure all out in few days because of your script as I just started undertsanding C# properly.
Same issue here, I'm not seeing in game or scene view
Discovered it was at 0,0 in my world, no matter whether I moved the gameobject's position. Still trying to figure this one out - will report back.
Rotating the line did it for me. Ultimately I went with using body parts as shown later in the video.
thanks, owen, you saved me
hey can somebody help me its saying that target is invalid even though I followed all the steps.
How do you do this with AI? That fish creature inspires me to make an aquarium style game and I'd like to know how to make it swim around on its own instead of following the mouse cursor. Also how would I move it with a joystick for controllers and mobile?
You would simply need to create a patrol script, and have the head rotate to face the patrol point. For controllers, same thing, just make a classic joystick script, and have it rotate to match the joystick movement. The tail will follow behind :) (for gamepads I recommend Rewired, awesome asset pack that makes the whole input system easy!)
It says something about vector and y and x not worky
Any thoughts on how to make something that wiggles consistently, but stays about the same length. I've tried a few things to make this but always end up with it either being too rigid and not really wiggling the whole length of the line, or it will wiggle nicely while holding still, but then it stretches out behind the creature when it moves.
2nd Code does not wiggle for me as well
Did you ever figure this out?
@@seahood_ , kind of. I did a lot of tweaking of the numbers and it worked close to how I wanted. Ultimately I ended up going a different direction anyway.
Despite how triggering I found the lack of polymorphism with these, it's a very helpful tutorial, thanks
There is a problem with generating colliders and sorting point for rendering. I think 2D Inverse Kinematics is better solution.
I know its been 2 years, but how would you go about taking it a step further to simulate like a real life tail that sorta flops around like the rainworld slugcat tail?
How many of you guys are curious on how to improvise making Celeste like hair?
Thank you Owen 😊
how can I add collision physics to the tentacles?, you know... to not clip in the walls
Can you do the same tutorial but for 3d?
Wiggledir might be my new favorite word.
i am trying to actually make animation that is as smooth as rain world. It may be hard but i think i can do it
Thanks Owen!
Nice tutorial
Really appreciate it
I can’t seem to get my Tentacle 1 object to move
Don’t know why
Nice video good job 👏
Thank you Owen
I'm super interested in the way that fox's head was made. Is he 2d as well? Looks more 3d or perhaps 2d perspective code manipulation
I really try to recreate the tail of the fox in a character and I can't do it T_T, it gets longer all the time and if I manage to stop it from getting longer it doesn't move naturally. Thanks for the video!
How to make glide in unity for 2d game?????? Plzzzzzzzz help
I love this tutorial! but i have a very big doubt... does anyone knows how to make those wings on min 12:18?? i'm not so good at coding so i could't figure it out, i'd aprecciate if someone knows how i could do something similar. Cheers!
hi, love your content! may I ask one question: is there anyway I can make a tile- base plant ( seaweed for example) that apply this procedural animation and can be add or remove length? Thanks in advance
Good job!!! Do you have any discounts for buying multiple of your courses at once?
Thanks :) Unfortunately Udemy doesn't offer a solution for making course bundles. Perhaps in the future we'll make our own website for students to purchase our courses, and offer discounts. But at the moment we don't have much control over that.
Yeah, this is a really nice vid