Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Fake 3D effect

edited December 2013 in General Posts: 577

Hi! In a game I'm working on, you are a Indian collecting food in the woods. I found a slight annoyance though. The collision is only on the bark, since I want people to be able to go behind the trees. But, then they are on the leaves. I feel like I could fix this by making the sprites vec2 to a vec3, I'm I right?

Thanks,

Prynok

Comments

  • IgnatzIgnatz Mod
    Posts: 5,396

    @Prynok - there are quite a number of issues with working with trees in 3D, some of which you may have discovered. I'm not sure how a vec3 is going to solve your problem, though.

    wrt collisions, I would simply set a circle of (say) 20 pixels at the position of each tree, and call it a collision if the player gets closer than that.

    If you are making a 3D scene, and if the camera moves among the trees, you may want to look at tutorials I wrote about this. A technique called billboarding is very useful, and you need to sort your trees by distance, to prevent pixel effects. And you should look at using shaders to discard transparent pixels in each tree image.

  • Posts: 577

    @Ignatz I'm not making a 3D scene, Its a 2D game from a top-down view, my problem was when I set the collision to just the bark , the players can walk on the tree. I don't think I'm advanced enough to make 3D trees :P

  • IgnatzIgnatz Mod
    edited December 2013 Posts: 5,396

    @Prynok - ok, then why not still define a collison as being a circle of N pixels around the bottom of the tree, then your only problem is drawing the player so they are behind the tree if they move higher than its base.

    You can do this by sorting the trees based on distance from the camera, then draw them from furthest to nearest, checking all the time whether the player is further than the next tree to be drawn. If that is the case, you draw the player, then keep drawing the rest of the trees. Then your player will be drawn behind the tree at the right time.

  • IgnatzIgnatz Mod
    Posts: 5,396

    You can make trees look 3D so that the camera can walk among them, by rotating them so they always face the camera and you never see them side on. This is called billboarding, and works really well with trees.

  • edited December 2013 Posts: 835

    EDIT Comment No Longer Relevant

  • Posts: 577

    @CodeaNoob I was actually referring to the people from India, as I did my research on them.

Sign In or Register to comment.