can anyone help me… im doing a marble game and one of my requirement in the game is to calculate the total distance of the marble from its current position up to its present position…
and also anyone who can help me in terms of respawn… where the marble will respawn in its last location when it got out of bounds
A few simple lines of python could be used for this. I have this site bookmarked that may help you. First to find the distance, I’d use the getDistanceTo method, which returns the distance to a specified object. Check out this page for more info and some example code.
As for respawning, I assume you don’t mean just restarting the scene? To move an object to a specific point, use python to set the worldPosition variable. Again, see this page for more info on that. You can also set the worldPosition to equal another object’s worldPosition.
If you need help on how to use python in the game let me know.
PS: if you are wondering “why this guy wrote “(p1[0]-p2[0])” multiplied itself instead of using squared” its because i dont know how to square in python :o (I`ve tried using ^2 but didn’t worked)
edit: just saw extramedicated site, didnt knew was a function for that
tnx mate… ill try it… im studying python scripts… and yah i really need help in the game im developing… tnx a lot… keep in touch… ill ask other question bout the game when i encounter another one… tnx alot…
by the away do you know how to network a turn base? for instance… (LAN CONNECTION ONLY) ** For instance player 1 will shoot the marble the next player will be next and so on… max players is 4…
by the way can you provide a blend file for me to peak?.. wondering how will it work… tnx mate
but what show in the play mode is the distance from the center and cube only
the distance from the object i added didn’t show up… the object i used is plane…
I can’t download your file. It just redirects me to an ad and never starts the download. I suggest ditching that file-hosting site in favor of one like fileden or mediafire. Or you can just attach it to your message.
Your code looks like it should work. The only thing I can say without seeing the blend is to make sure you spelled the objects name correctly. (“OBTry” or “OBtry”)
I can’t download your file. It just redirects me to an ad and never starts the download. I suggest ditching that file-hosting site in favor of one like fileden or mediafire. Or you can just attach it to your message.
Your code looks like it should work. The only thing I can say without seeing the blend is to make sure you spelled the objects name correctly. (“OBTry” or “OBtry”)
The ball doesn’t have a distance to plane property.
Add a property to the ball and name it “distance_from_plane” or whatever you called it in the script. Then you can click on the little button with the ‘D’ next to the property so that it shows up when the game runs.
The ball doesn’t have a distance to plane property.
Add a property to the ball and name it “distance_from_plane” or whatever you called it in the script. Then you can click on the little button with the ‘D’ next to the property so that it shows up when the game runs.
[/quote]
i got it tnx man… i also have anothr problem can you help me…
The linear velocity needs three numbers to work. Add a 0.
The last line is just a simple mistake. You defined the actuator as “actAct” and you tried to activate “act”. Just add “Act” to that and it should work.
Is the power level supposed to increase when you hold space down? If it is, I could try to find out why it’s not increasing.
I should have noticed this earlier, but you should turn on the pulse mode of the sensor so it can keep running the script when you hold space. That should work.
welll i got the logic of the distance… bat wat im trying to add now is… im mixing the ball in the power… with the distance…
heres the logic…
when the ball is release from its current location… the distance from the current location together with the present location of the ball when it reaches its maximum location when the power is released… will be calculated…
then when enter is press… the ball can be have power again and the calculation will reset again… but not from the first location bat from the 2nd location and present location when the power is release…
kinda complicated… hard to explain when u need a sample file … im willing to do my logic and post it here…
Do you mean that you want it to show the total distance for each shot?
If so, it shouldn’t be too hard, but I’ll have to think about it. I’m thinking of storing the location of the ball before the shot and the ball when the velocity returns to zero, and getting the distance between those points.
Is this the kind of thing you were trying to do?