Teleport object - onCollide script
24 posts • Page 1 of 1
Teleport object - onCollide script
Hello everyone,
I have been trying to make a teleporter (I would use it in water simulations). It is a simple box with an onCollide script that should change the coordinates of the object colliding with the box.
I tried this code:
There doesnt seem to be a syntax error because the objet is loaded and I can see the code in the Script Menu. It just doesn't work, and I don't know why.
So, if anyone can help, it woud be great!
I have been trying to make a teleporter (I would use it in water simulations). It is a simple box with an onCollide script that should change the coordinates of the object colliding with the box.
I tried this code:
- Code: Select all
onCollide = (e)=>{e.other.pos=e.pos+[1,1]}
There doesnt seem to be a syntax error because the objet is loaded and I can see the code in the Script Menu. It just doesn't work, and I don't know why.
So, if anyone can help, it woud be great!
- leroidangleterre
- Posts: 12
- Joined: Fri Sep 06, 2013 5:27 pm
Re: Teleport object - onCollide script
Everything fine. Are you sure you running 2.1.0 ? Are you sure it's collided (set App.drawCollisions = true to see collision points)?
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Teleport object - onCollide script
I tried it too, and it works just fine as expected. If the problem isn't what kilinich suggested, then you might have something else going on that we don't know about because we don't know what your scene looks like. So, it would be very helpful if you could upload your scene to this forum so that we could take a look at it.
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Teleport object - onCollide script
Works fine with boxes, not with water.
Does water actually have an editable 'pos' option? Could be to do with how water uses 'vecs'. Although e.other.vecs doesn't do anything either..
And trying to get the position of the water by storing it in a variable doesnt work
I hope this helps somewhat!
Does water actually have an editable 'pos' option? Could be to do with how water uses 'vecs'. Although e.other.vecs doesn't do anything either..
And trying to get the position of the water by storing it in a variable doesnt work
I hope this helps somewhat!
- MrGlinzz
- Posts: 13
- Joined: Tue Mar 19, 2013 11:51 pm
Re: Teleport object - onCollide script
Can we even run code against water, I don't think that we actually can.
I know water triggers onCollide on geometries, but I don't think water supports e.other, as technically it's not a geometry!
I don't think algodoo even really gives water their own variables, other than for location and velocity.
I know water triggers onCollide on geometries, but I don't think water supports e.other, as technically it's not a geometry!
I don't think algodoo even really gives water their own variables, other than for location and velocity.
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: Teleport object - onCollide script
PROBLEM DETECTED!
your problem is that you are probably putting in [1,1],you need 3 numbers in there,so,to change the just the X coord is just having [1,0,0],while Y is [0,1,0](not sure what third is)
your problem is that you are probably putting in [1,1],you need 3 numbers in there,so,to change the just the X coord is just having [1,0,0],while Y is [0,1,0](not sure what third is)
- VZstrikez08
- Posts: 6
- Joined: Fri Nov 08, 2013 1:39 am
Re: Teleport object - onCollide script
VZstrikez08 - What are you talking about? The object position array has only two values (one for X pos, and one for Y pos), not three. What makes you think there are three numbers?
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Teleport object - onCollide script
Epic fail on my part.Must have had some hallucinations.I'll go get that checked out.
- VZstrikez08
- Posts: 6
- Joined: Fri Nov 08, 2013 1:39 am
Re: Teleport object - onCollide script
VZstrikez08 wrote:Epic fail on my part.Must have had some hallucinations.I'll go get that checked out.
No problem. We all have those brain farts occasionally. I suspect that you were thinking in 3 dimensions (x,y,z), but Algodoo is a 2D simulation program, so, unfortunately, we do not have a third dimension (z) to play with. Maybe some day Algoryx will produce a 3D version of Algodoo, but I'm not holding my breath.
Regards,
Xray
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Teleport object - onCollide script
Just a personal note..... Is it just me, or do other people get bothered when a user asks for help (such as this user, leroidangleterre ) and a number of people jump in with suggestions to resolve his issue, and you never hear from him again? It seems rude that in two weeks time he wasn't able to chime in to let us know that either:
1. One of our suggestions resolved his issue.
2. He resolved it himself.
3. He is no longer interested in this issue or for any other reason, no longer needs our help.
In two weeks time, he could have given us the courtesy of replying, if for no other reason but to acknowledge our assistance, and maybe even to express a little gratitude.
Maybe I'm being a little overly sensitive about this, but I felt the need to spout off about it.
Thanks for listening.
1. One of our suggestions resolved his issue.
2. He resolved it himself.
3. He is no longer interested in this issue or for any other reason, no longer needs our help.
In two weeks time, he could have given us the courtesy of replying, if for no other reason but to acknowledge our assistance, and maybe even to express a little gratitude.
Maybe I'm being a little overly sensitive about this, but I felt the need to spout off about it.
Thanks for listening.
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Teleport object - onCollide script
they got one, it's called AgX Multiphysics, but it's definitely probably™ not free (in fact there isn't even a price on it, a buyer must contact Algoryx for information)Xray wrote:Maybe some day Algoryx will produce a 3D version of Algodoo, but I'm not holding my breath.
Regards,
Xray
it happens, people either post and forget, or decide to abandon the project, or become too busy to work on the project. while I agree that it is frustrating that he hasn't responded, I don't feel it's rude. rudeness would require deliberation. I apply excessive amounts of Hanlon's razor in these matters.Xray wrote:Just a personal note..... Is it just me, or do other people get bothered when a user asks for help (such as this user, leroidangleterre ) and a number of people jump in with suggestions to resolve his issue, and you never hear from him again? It seems rude that in two weeks time he wasn't able to chime in to let us know that either:
1. One of our suggestions resolved his issue.
2. He resolved it himself.
3. He is no longer interested in this issue or for any other reason, no longer needs our help.
In two weeks time, he could have given us the courtesy of replying, if for no other reason but to acknowledge our assistance, and maybe even to express a little gratitude.
Maybe I'm being a little overly sensitive about this, but I felt the need to spout off about it.
Thanks for listening.
- jon_joy_1999
- Posts: 233
- Joined: Fri Dec 09, 2011 12:51 am
Re: Teleport object - onCollide script
Hi Jon_joy - Hanlon's Razor??? I'll have to look that up!
You are right about the OP possibly not being deliberate, and I may be a little too cynical. I just happen to be a little older than most people on this forum, and therefore I come from the old school of courtesy, manners, and consideration for others, which people now-a-days just don't seem to have as much of. I won't lose any sleep over it.
Thanks for your input!
You are right about the OP possibly not being deliberate, and I may be a little too cynical. I just happen to be a little older than most people on this forum, and therefore I come from the old school of courtesy, manners, and consideration for others, which people now-a-days just don't seem to have as much of. I won't lose any sleep over it.
Thanks for your input!
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Teleport object - onCollide script
Hello everyone,
First, I am sorry about the delay. I did not mean to be rude or to seem uninterested in your replies, but I had priorities that kept me away.
I tried a few things, including the display of the collisions, but I can't find out the origin of the problem. As you can see in the attached scene file, I see that a collision is detected between the box and the circles; I manage to change the color of the circles when the collision occurs. But I still can't change the position of the colliding object. Any idea why the code
Thank you (and this time I will try not to be AFK for too long
)!
First, I am sorry about the delay. I did not mean to be rude or to seem uninterested in your replies, but I had priorities that kept me away.
I tried a few things, including the display of the collisions, but I can't find out the origin of the problem. As you can see in the attached scene file, I see that a collision is detected between the box and the circles; I manage to change the color of the circles when the collision occurs. But I still can't change the position of the colliding object. Any idea why the code
- Code: Select all
onCollide = (e)=>{e.other.pos := e.this.pos + [0.0, 2.0]}
Thank you (and this time I will try not to be AFK for too long
- Attachments
-
teleporter.phz- (5.36 KiB) Downloaded 51 times
- leroidangleterre
- Posts: 12
- Joined: Fri Sep 06, 2013 5:27 pm
Re: Teleport object - onCollide script
I don't understand what you think the problem is because it is working exactly as you scripted it. Just working with one circle so as not to add too much confusion, as soon as the circle collides with the box, the circle translates to the pos of the box + [0.0,2.0], and the circle's color becomes the color of the box. What do you see is wrong with that? 
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Teleport object - onCollide script
Well, on my computer the circle changes its color but is not "teleported", as if the code
Thanks, anyway!
- Code: Select all
onCollide = (e)=>{e.other.pos := e.this.pos + [0.0, 2.0]}
Thanks, anyway!
- leroidangleterre
- Posts: 12
- Joined: Fri Sep 06, 2013 5:27 pm
Re: Teleport object - onCollide script
use = instead of := for existing variables/objects
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Teleport object - onCollide script
Ok, I reinstalled everythig with the latest version and this time, the teleportation worked 
I still feel frustrated because it ony works with solids, and not with water, and I would have liked that; anyway, this is funny enough for me right now.
And maybe I could write a specific script for regular circles that would make them act like water particles; but it would probably be easier to write my own Java or C application...
Thanks for your help and sorry again about not following my own post.
I still feel frustrated because it ony works with solids, and not with water, and I would have liked that; anyway, this is funny enough for me right now.
And maybe I could write a specific script for regular circles that would make them act like water particles; but it would probably be easier to write my own Java or C application...
Thanks for your help and sorry again about not following my own post.
- leroidangleterre
- Posts: 12
- Joined: Fri Sep 06, 2013 5:27 pm
Re: Teleport object - onCollide script
Yea, water don't call onCollide so you could not teleport it this way(
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Teleport object - onCollide script
Do you think there could be another way to teleport water? Would it be possible to turn water into a solid, then teleport it, and then change it to water again?
- leroidangleterre
- Posts: 12
- Joined: Fri Sep 06, 2013 5:27 pm
Re: Teleport object - onCollide script
You can freeze water (convert water into a polygon) but as far as I know, it can only be done manually through the edit menu:
Select the water that you want to freeze, then in the edit menu, select "Water options" and then select "Freeze water". You CAN liquefy a geometry such as a polygon which is frozen water. For example: onCollide = (e)=> [e.other.liquify}
The amount of control that we have over water is extremely limited. There have been attempts to simulate Algodoo water using circles, but the results (in my humble opinion) have been less than desirable. If you figure out a good way to simulate water using circles, please do share it with us!
Select the water that you want to freeze, then in the edit menu, select "Water options" and then select "Freeze water". You CAN liquefy a geometry such as a polygon which is frozen water. For example: onCollide = (e)=> [e.other.liquify}
The amount of control that we have over water is extremely limited. There have been attempts to simulate Algodoo water using circles, but the results (in my humble opinion) have been less than desirable. If you figure out a good way to simulate water using circles, please do share it with us!
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: Teleport object - onCollide script
Water has only three variables. But water actually registers onCollide, but you can't register it from water.
Here are the variables:
vecs - water's position (every water particle has its own variable)
vels - water's velocity
version - idk what is this
Want proof?
Add a small circle (0.01 - 0.06m) and liquify it. You got one particle of water.
Now copy the water and add that code on a solid object on onCollide().
You will see that there are only three variables. Now play the scene and woala! It registers onCollide but only on an solid object.
Code:
PS. Xray replied while I was still writing.
EDIT: I was trying to edit the vecs variable to teleport water in that way. Water actually does not register itself on e.other.
Here are the variables:
vecs - water's position (every water particle has its own variable)
vels - water's velocity
version - idk what is this
Want proof?
Add a small circle (0.01 - 0.06m) and liquify it. You got one particle of water.
Now copy the water and add that code on a solid object on onCollide().
You will see that there are only three variables. Now play the scene and woala! It registers onCollide but only on an solid object.
Code:
- Code: Select all
Scene.addWater({
vecs := [[11.462126, 5.2153082]];
vels := [[0.0, 0.0]];
version := 4
})
PS. Xray replied while I was still writing.
EDIT: I was trying to edit the vecs variable to teleport water in that way. Water actually does not register itself on e.other.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- Luka
- Posts: 17
- Joined: Wed Oct 23, 2013 12:57 pm
- Location: pos[0, 0]
Re: Teleport object - onCollide script
I am currently working on a separate program to apply the SPH technique. As soon as I am done with it, I will try to apply these equations to a regular circle in Algodoo, and I will see what I get. If successful, I'll let you know!
- leroidangleterre
- Posts: 12
- Joined: Fri Sep 06, 2013 5:27 pm
Re: Teleport object - onCollide script
"// Phun scene created by Phun v5.28"
Eeeerm, guuys, according to the scene he passed he is running Phun.
Eeeerm, guuys, according to the scene he passed he is running Phun.
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: Teleport object - onCollide script
electronicboy wrote:"// Phun scene created by Phun v5.28"
Eeeerm, guuys, according to the scene he passed he is running Phun.
True, but then later he replied: Ok, I reinstalled everythig with the latest version and this time, the teleportation worked"
-

Xray - Posts: 501
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
24 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests




