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! :)
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...
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!
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!
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 :)
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
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); } }
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 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? 😉
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. ❤️
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.
@@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.)
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!
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); } }
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)
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 :)
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?
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.
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
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 :)
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...
I LIKE THAT TITLE! Thanks for this tutorial ,it's really appreciated!
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!
Dang this is so cool! I'm gonna try this in my current devlog project, thanks for sharing this :D
This is so amazing! I always adored these smooth juicy Trails, Thank you so much for sharing this amazing tutorial noa and owen!
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….
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!
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
Perfect timing, exactly what I needed right now, thanks!
As always, super fun, super informative and super easy to understand. May the Lord bless you always.
Super cool Noa! Now I just need to figure out what to use this for in our 2D world 😀
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 :)
Thank you. Powerful examples inspired me to use this way instead of animation keys.
BlackThornProd you are a god
Your art is great and there is nothing to hate
Your the best keep up the good work
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
Welcome back tutorials.......
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);
}
}
You are back to tutorials I like that
What a great use of the Line Renderer. Nice one dude
Really nice effect. Ive been using the built in particle system's trail module for basic trails at the moment
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.
This was super fun to make! Thank you blackthornprod and Owen for sharing :)
everyone say it with me... thanks owen senior and noa! it looks great
definitely saving this one for later
This is awesome! I love doing procedural animations on gamemaker, so your video made me super exited to try it on unity!
Black On The Block! Great as usual! Black is the new Brackey!
awesome stuff, Owen and Blackthornprod. Would love to see tutorial for 3D effect!
I am gonna add this technique to my sprite mask and modify it a bit..... thanks for the tutorial btw
Dude who made it THANK YOU!!!!
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? 😉
I'm a Man of Culture and I have seen Enough Tentacles to know where this is going ✨
n O
How would one go about procedurally animating the clothes like the ones on the character from 0:34 to 0:37?
Finally some quality tutorial :) Good job !
It’s been a long time since I watched blackthornprod :)
Welcome back :)!
Some really nice uses for the line renderer, now I just need to learn to make art.
Vraiment les meilleur Tutorial. Merci :)
The best Tutorials man I LOVE YOU
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?
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. ❤️
Very beautiful effects.
Amazing! Thank you so much for uploading! ;)
Great, thanks, just what I was looking for.
That’s very cool thanks for sharing and shoutout to Owen)
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
Now this is *something* else
Nice video! I´ll 100% use this for one of my games
Amazing effects. Is it possible to have mesh/rigidbody effects on these trails? That will allow them to have colliders and give/take damage....
Gotta save this for later
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
Awesome, thank you! You seem to always notice where there is a tutorial gap on youtube :)
_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
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! 🤘
Another good tutorial as always!
I was looking for this, thank you so much man
If only I had seen this earlier. This looks awesome :)
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);
}
}
thanks, owen, you saved me
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);
}
Thank you Owen 😊
Hey great tutorial noa !👍
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
Thanks Owen!
thank you owen
Wiggledir might be my new favorite word.
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?
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 :)
Awesome work!
Thanks... very good tutorial
Really love your vids, just a request, please post videos more often.....Thanks....!!!!
Nice video good job 👏
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);
}
Thank you Owen
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 ?
Beautiful
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?
Yeah, this is a really nice vid
Now I can finally make the glocktopus
Welcome back to the real world!
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 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!)
PERFECT NOW WE DO NOT HAVE TO USE CLOATH SIMS
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
using System.Collections;
using System. Collections. Generic;
using UnityEngine;
public class TentacleTwo : MonoBehaviour
{
public int length; public LineRenderer lineRend; public Vector3[] segmentPoses; private Vector3[] segmentV;
public Transform targetDir; public float targetDist; public float smoothSpeed;
public float wiggleSpeed; public float wiggleMagnitude; public Transform wiggleDir;
public Transform tailEnd;
private void Start() {
lineRend.positionCount = length; segmentPoses = new Vector3[length]; segmentV = new Vector3[length];
}
private void Update()
{
wiggleDir.localRotation = Quaternion.Euler(0, 0, Mathf.Sin(Time.time * wiggleSpeed) * wiggleMagnitude);
segmentPoses[0] = targetDir.position;
for (int i = 1; i < segmentPoses.Length; i++)
Vector3 targetPos = segmentPoses[i - 1] + (segmentPoses[i] - segmentPoses[i - 1]).normalized * targetDist; segmentPoses[i] = Vector3.SmoothDamp(segmentPoses[i], targetPos, ro( segmentV[i], smoothSpeed);
} lineRend.SetPositions(segmentPoses);
tailEnd.position = segmentPoses[segmentPoses.Length -1];
public class BodyRotation : MonoBehaviour
}
public float speed;
private Vector2 direction;
public Transform target;
private void Update() {
direction = target.position - 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, speed * Time.deltaTime);
}
}
ur a king
How many of you guys are curious on how to improvise making Celeste like hair?
Excelente..!!!, muchas gracias..!!
It says something about vector and y and x not worky
Can you do the same tutorial but for 3d?
reminds me of the game flOw I used to play on xgen studios
Ah, this is why I like you so much hahahaha! 😂 you are a Brushian ;)
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
Nice tutorial
Really appreciate it
I can’t seem to get my Tentacle 1 object to move
Don’t know why
Noah made a song its called "DIR"