[SOLVED]Spawn circle that has inherited variables

About advanced scenes, and the Thyme scripting language used in Algodoo.

[SOLVED]Spawn circle that has inherited variables

Postby HQTG1 » Thu Nov 03, 2016 5:33 am

I couldn't figure out how to word the title any better, but here's what I'm trying to do: I have a laser that spawns a circle on the point that it hits, for use in an engine. I need to have the circle inherit the velocity of the object that the laser is attached to, because the speed of the engine is severely limited by this (Lets say I have a car traveling at 15 m/s, but it can't go any faster because it has to accelerate the circles being spawned in the engine up to that speed.) I know this is really easy using scene variables, but I would prefer not to use them because it makes having multiple cylinders a massive hassle.
Last edited by HQTG1 on Mon Jul 10, 2017 11:00 pm, edited 1 time in total.
User avatar
HQTG1
 
Posts: 2
Joined: Thu Nov 03, 2016 5:12 am

Re: Spawn circle that has inherited variables

Postby Kilinich » Thu Nov 03, 2016 9:34 am

Just add set vel (and angvel if needed) of circles:

In onLaserHit:
Code: Select all
(e) => {
  scene.addCirclre({
    pos := e.pos;
    vel := e.geom.vel;
    angvel := e.geom.angvel;
    ...
  })
}
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Spawn circle that has inherited variables

Postby FRA32 » Thu Nov 10, 2016 9:30 pm

First, before creating the object, get an instance of the object the laser is attached to:

base := scene.entitybygeomid((readable(owner)).geom);

then simply call its vel

scene.addCircle({
...
vel := base.vel
...
})
FRA32
 
Posts: 229
Joined: Wed Dec 03, 2014 9:51 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 8 guests