Browse Search Popular Register Upload Rules User list Login:
Can somebody help me out?

screenshot of the scene

Author: Ravenplucker

Group: Default

Filesize: 52.83 kB

Date added: 2016-07-29

Rating: 5

Downloads: 284

Views: 290

Comments: 12

Ratings: 1

Times favored: 0

Made with: Algodoo v2.1.0


Scene tag

I have no idea how to script, and I figured I'd make a scene here instead of the forums since they are so dead. I'd be awesome if someone could help me out.

I need a script I can put onto a laser

if the laser collides with something
change collision group of the polygon it's attached to to C
otherwise polygon doesn't collide

credit would ofc be given if I manage to build the thing I have planned :*)
Please log in to rate this scene
Responses to this scene:
Title Author Rating Downloads Comments Date added
Laser help scene for Ravenplucker Xray 5 (1 vote) 302 2 2016/07/30 05:23:36
Ravenplucker's Laser carl00s01 5 (1 vote) 62 1 2016/07/30 04:03:00
show grid
Question: You said "change collision group of the polygon it's attached to to C", but the laser is attached to a BOX, not a polygon. Is that Okay? Or did you really want the laser attached to a polygon?
To a polygon would be good, but even better if it works for both if that's possible.
Just a little comment on the script if you want to know/do more:

"my_box := Scene.entityByGeomID((readable(entity)).geom); "

will get the geometry the laser is attached to. With this you can edit every property of the attached geometry, for example:

"my_box.friction = 0.0;"

will make the box frictionless.

This is the main part:

_Hit ? {
my_box.CollideSet = 4
} : {
my_box.CollideSet = 0

It checks if the laser is hitting any target and everything that you put inside the first braces will be executed if the laser is hitting, and everything inside the last braces will executed otherwise.

CollideSet numbers works as follows: A is 1, B is 2, C is 4, and so on... Any combination of them is just the unique sum of these powers of two, [A,B] is 3, [B,C] is 6, and so on
Last edited at 2016/07/30 04:37:15 by carl00s01
Carl you are fantastic <3333333333333333333333333
There's another way to skin the cat! See my response scene.....
You forgot to turn the collideSet to 0 whenever it isn't hitting anything...
OOPS! You're right! I'll see if I can fix it.

Thanks! :tup:
That was my problem: there is no "onLaserNotHit" function that is overridden by the "onLaserHit" one:P , but if you put the default case (_Hit = false) inside the update() it will work.
Okay, I fixed it with a counter. Thanks again for catching that! :)
(comment deleted).
Last edited at 2016/07/30 06:12:21 by Xray

1 press F10
2 writte "", like or, then add + "=(value)" or "="(string)" "
3 go in the laser, click on "script menu"
4 find for onLaserHit and write "(e)=>{ thig you have created) = 1}
5 go on the attatched object and on the collide set writte "{ you know)}

If you want the value of them returns to initial, use the update of the laser

If you want I can make a map exemplifying that