2d beat em up

Started by
11 comments, last by Nikolasi 7 years, 1 month ago
Here we go, if someone can help me explain how to do it in front of and behind the object:
script:
problem:
Advertisement

It really helps if you mention Unity too in the title or the tags, very few know what programming system you use.

Judging from lines 42 through 45, I'm guessing this thread is about draw order and not something that would require the green character to get up from that chair. You'll need more logic than a single horizontal line check. Research bounding box.

I try use http://www.coatbros.com/blog/2015/03/ but it dont work.I dont know why.

Come on https://www.twitch.tv/rasetocsgo to help me.

A line check should work in this case as long as the sprite origins are at the feet, not the center or top. Check in your sprite import settings, or apply the sprite/bounding box height as an offset.

EDIT: Looking at the code, Vector3.Set doesn't work on transform vectors. You have to manually set the entire vector reference to a separate Vector object:


if (transform.position.y > Object.transform.position.y) {
{
        // doesn't work
        transform.position.Set(transform.position.x, transform.position.y, -1);

        // does work
        transform.position = new Vector3(transform.position.x, transform.position.y, -1);
}

A line check should work in this case as long as the sprite origins are at the feet, not the center or top. Check in your sprite import settings, or apply the sprite/bounding box height as an offset.

EDIT: Looking at the code, Vector3.Set doesn't work on transform vectors. You have to manually set the entire vector reference to a separate Vector object:


if (transform.position.y > Object.transform.position.y) {
{
        // doesn't work
        transform.position.Set(transform.position.x, transform.position.y, -1);

        // does work
        transform.position = new Vector3(transform.position.x, transform.position.y, -1);
}

Object.transform doesn't exist

http://i.imgur.com/VecpKVU.png

http://pastebin.com/kF67xrwt

That was copy and pasted from your original code. Making a new Vector3 is the main point.

That was copy and pasted from your original code. Making a new Vector3 is the main point.

Look still dont work: http://i.imgur.com/h17uIzb.png

Script isnt completed.
Look:
[video=youtube]https:
[/video]
Script:
Code need debug.

This topic is closed to new replies.

Advertisement