|
So im making a SORPG (singpleplayer offline role playing game) and im currently working on a harvest tree type of resource gathering. What i m trying to do is when you are within 8 "distance" from the tree you can bring up the menu by left clicking (right click is reserved for my camera script) upon clicking ( and i know that he, meaning my player1, is close enough to the tree the menu does not appear) Code:
The Thanks for the help, Raul PS. don't point out horrible structure im a newbie.
(comments are locked)
|
|
You're testing against nothing with your magnitude, as wanted position hasn't been setup properly. You're using the values from hit, however you haven't performed the Raycast at that point, so hit doesn't actually contain any data yet. I believe by default that means you're actually always setting wanted position to 0,0,0 which will always fail your distance test. so how would i get the playerDist before going into the if statement?
Oct 16 '10 at 12:36 AM
RaulDiaz
Remember that aside from statements that change the flow of control, the code will be executed in order, statement by statement. In order to get your code to do what you're wanting, you need to think about the logical flow of events and what depends on what, and then write your code accordingly. I'm not completely clear on what you're trying to do, but just as an example, if whether the menu comes up is dependent on whether the item that was clicked is within a certain distance of the player, you need to determine what item was clicked, then check the distance to the player.
Oct 16 '10 at 03:53 AM
Jesse Anders
I understand but how would i go about doing this i rewrote the code but it no longer works. it only outputs 0 as the distance? an ideas?
Oct 16 '10 at 07:53 PM
RaulDiaz
(comments are locked)
|
