Hi, everyone.
I’m not a native English speaker, so sorry for reading my poor English first.
I have a question which I have not clue how to do it.
I’m trying to create a dynamic mesh that can climb the wall just like the gif I posted.
In the gif, I use shadow to simulate the effect.
Can anyone tell me if it’s possible to use the dynamic mesh making this kind of climbing effect?
Or if there’re another better ways to do it?
I’ve a little tried after seeing your reply,
but it seems the cookie can only have one color.
It doesn’t meet what I want.
I want a flat object with texture and collider.
The decal systems is great!
But I still suffer some problems.
The decal systems use the bounding box to project texture.
It will create a whole mesh, so if I use the mesh collider, the whole mesh will be detected as collider.
It’s weird if the texture’s transparent parts is detected.
If there’s any way to only detect the texture’s non transparent parts?
And the other thing is, when I’m trying to calculate the normals to get the best rotation of the decals.
I found that contact points of collision can help me, but I can’t just use the OnCollisionEnter.
So I have to use OnTriggerEnter, but with this method I can’t use contact points.
Because I’m using the decal systems dynamically, so I need to dynamically find the correct rotation of decal to project texture right.
The problem of collider is I only want to detect specific area (like the black part in the image), but decal project whole mesh with texture so it’s not possible to use mesh collider.
I want to ask if there is another way to do it?
The second question is I need to dynamically use decal in the game just like the gif. I post in the #1.
So I have to dynamically rotate decal object.
For example, if I want to use decal to climb the wall, decal need to rotate if it touchs another mesh (like the image).
I try to get the normals of two planes and calculate the best angle to rotate,
but I didn’t find the proper way to accomplish.
I didn’t make it clear enough. My question was, why you need it. Depending on your case, you may use exactly this solution, but with a few tricks.
If you want a tighter mesh, you need to perform more cuts to achieve the circular shape. I don’t know which solution you are using, but it is most likely quite some work to get that.
The effect you are showing there is different. It is not one projection, but two. One onto the floor and another one onto the wall. The difficulty would be to find the correct position for that.
Using just one projector, will most likely be simpler. As you got the hit point, you may go backwards for a certain amount. Either backwards along the ray or the normal. Now from the position, I would make further raycasts towards the ground of the projector. At least towards all the corners. Now you have the original ray and the corner ones. You may use the normals of them to calculate the rotation. In order to get smoother behavior over time, you need to give each normal a weight. The closer the hit point to the origin, the higher the weight. Now take the sum of those weighted normals and normalize it. This should give you a relatively stable basis. If you increase the number of raycasts, you will most likey also get a more stable result.
I’m not sure if it works just like the system, “Decal System Pro”, your team designed.
I’m not really understood what did you mean two projections.
This system only have one box projector.
The meshs onto the wall and floor are the mesh it crops.
And the further raycasts is like this?
[Blue is the original ray, green is the cornor rays.]
What do you mean with “When player use it”? If it needs to be selectable with the mouse, you may use the raycast hit information to check whether an invisible or visible part on the texture was clicked.
My team consists of myself . The underlying ideas are identical.
The gif you are showing looks as if two projections take place. One straight down and the other straight onto the wall.
I would try to avoid any upward raycast. But at the end you just need something that is believable.
It’s not being selectable with mouse.
When player input a key to use this skill, they will become the object similar to the shadow.
Then uses the Horizontal and Vertical Input to move this object.
I forgot to tell another mechanics in this game. :|
The collider is used to detect whether any light hit the black part.
If hit, the player will get hurt.
That’s why I only need to detect visible part on the texture.
Wow! I thought it was created by a team. XD
Oh! I got it. Sorry that I didn’t explain properly.
Thanks for the tips! I haven’t thought about this.
Instead of using the collision detection directly, you may consider to use a sphere cast in the direction of the projection, to find the touching objects. For this kind of situation it is often needed to find creative solutions.
After a few days of trying.
I found that I just need to attach one capsule collider and automatically adjust it for some specific angles.
Although the result is not very precise, it’s still enough.
Before this I alway wants to get the collider as precise as possible.
I thought I just forgot the KISS principle. :P
Using the raycast to get normals is work pretty good, but still have some problems.
In some corners (like the picture below), the raycast can’t get normals correctly.
I have tried to create some rays onto the cube’s border and shoot to the original ray’s point, but the whole decal object will rotate crazily.
Download Unity’s built-in shaders, pick the transparent one that you are using, give it a new name, change it such that it doesn’t ignore projectors. That should do the trick.
I found an easy but not very good way to do this.
Putting a lot of box triggers at every corners and places where the player will go.
The decal will rotate angle or do another things according to the trigger it stays.
It works quite great, but it spends too much time on putting these box triggers.
So I might need to write an editor to make it easier.