Jump to content
  • Advertisement
Sign in to follow this  
Nikolasi

2d beat em up

This topic is 633 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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.

Share this post


Link to post
Share on other sites

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);
}
Edited by cmac

Share this post


Link to post
Share on other sites

 

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

Share this post


Link to post
Share on other sites
That was copy and pasted from your original code. Making a new Vector3 is the main point.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!