Terrible Tree Trouble

0 favourites
From the Asset Store
in 2D realistic Trees are included 26 realistic trees in different stems.
  • Alright, I am beating my skull over this problem, and I just can't figure it out.

    I'm making a tower defense type game, and you can build towers on any tree on the map. I put in my tree sprite, and control-drug the tree to create multiple yet identical trees on the map.

    I then made it to where when the player avatar collides with a tree, it turns to 75% opacity (to show that tree is activated) and turns a buildable boolean to "true." I then made it to where when the player avatar is no longer overlapping "tree," opacity is set back to 100% and the boolean becomes "false."

    You already see what I didn't, right? If you walk from one tree directly into another tree, BOTH trees activate because I never technically stopped overlapping "tree." In fact, if I don't actually leave the forest, and I walk from tree to tree, I can "activate" 20 different trees if I want, and none of them go back to 100% opacity because I never stopped interacting with "tree." I need to make all of the trees individual instances so when I move from tree to tree the boolean and opacity resets for the tree I just left.

    Does this make sense?

  • You could store the UID of the current tree, Pick all, and then do a foreach on the trees, resetting the values UNLESS the UID is the "current" one - turn those values on.

  • I thought I would have to use the UIDs for this as well, but all the commands I tried were wanting a specific UID instead of a range. Would you mind elaborating a bit more on what you mean? I think you might be on to something here, but I am unclear how to do the first couple of steps you outlines. Thank you so much for the help. I really appreciate it.

  • treesample

    See event #9.

  • Thank you very much. I have been at work all day so I didn't get to reply before now, but I really appreciate your expedient response. I will work on this problem tonight based upon the information you provided.

    I wish I could have replied to this without bumping the thread since it is such a focused issue. Sorry about that. :\</p>

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The link to the capx isn't working. I think the hosting site is having DNS issues or something. I'll try again later. Thanks again. I really appreciate it.

  • treesample.ZIP

    Change .ZIP to .CAPX.

  • Thanks for the blackhornet. The code worked brilliantly for solving the majority of the problem, but now the last tree touched won't revert to 100% opacity when I leave the trees. I tried adding an additional condition for "when player is no longer overlapping tree, set opacity to 100%." That didn't solve the problem.

    You got me really close though. Brilliant. I certainly appreciate it very much, and the extra effort you put into re-posting the link since the initial link was dead. Kudos sir. Let me know if there is anything I can help you with.

  • mmm I usually just Force a 'For each "tree condition on stuff like that and it works fine for me...have you tried that?

    Try putting the trees in a Family then add an extra condition "For Each->(TreeFamily)....

    that usually works for me....

    Its not usually necessary but sometimes FORCING the condition works more consistantly

  • I'll try forcing it and see if it works. Hopefully the conditions don't press charges.

  • A-HA! I fixed it by slightly modifying the last .ZIP blackhornet sent.

    Player is not overlapping tree

       Trigger once while true > Tree opacity 100%

  • This is what the functionality looks like for anyone in the future who stumbles across a similar problem. Thanks for all the help guys!

    <img src="http://i44.tinypic.com/2vknkae.jpg" border="0" />

  • I believe this would work as well:

    Every tick: Set tree opacity to 100

    Player is overlapping a tree: Set opacity to 25

    No need to hassle with uids or loops :-)

  • That doesn't work for the same reason that my original couple of simple ideas didn't work: there might be 30 trees on the map, but there is really only 1 "tree." You have to use the UIDs to distinguish between different instances of trees in order to individualize each tree, or else the opacity will be set to 75% for each consecutive tree you walk into without it reverting to 100% until you aren't touching ANY trees.

    You just end up with half of the trees being transparent that way. :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)