# CBEffects : Rotate vent to match object rotation

**URL:** <https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543>\
**Category:** Gymbyl Coding\
**Created:** [May 25, 2016, 4:30pm UTC](https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543 "2016-05-25T16:30:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Appletreeman](https://forums.solar2d.com/user_avatar/forums.solar2d.com/appletreeman/32/130_2.png) [@Appletreeman](https://forums.solar2d.com/u/Appletreeman)\
**Post date:** [May 25, 2016, 4:30pm UTC](https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543/1 "2016-05-25T16:30:48Z")

</div>

Hi, I’m just getting started with CBE and I’m liking it so far. &nbsp;In my current project I have a player ship that can be rotated through 360 degrees, and I’d like an emitter&nbsp;a vent to rotate with it for an exhaust effect.

Looking through the docs I can’t see anything obvious that would enable me to do this. &nbsp;Is it possible, and if so how?

Many thanks.

---

<div class="post-metadata">

**Author:** ![torbenratzlaff](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/t/c2a13f/32.png) [@torbenratzlaff](https://forums.solar2d.com/u/torbenratzlaff)\
**Post date:** [May 25, 2016, 5:45pm UTC](https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543/2 "2016-05-25T17:45:27Z")

</div>

An emitter object has the “angle” property, as stated in the docs.

[https://docs.coronalabs.com/api/type/EmitterObject/index.html](https://docs.coronalabs.com/api/type/EmitterObject/index.html)

Mabye you could ajust it to your needs?

---

<div class="post-metadata">

**Author:** ![Appletreeman](https://forums.solar2d.com/user_avatar/forums.solar2d.com/appletreeman/32/130_2.png) [@Appletreeman](https://forums.solar2d.com/u/Appletreeman)\
**Post date:** [May 26, 2016, 9:16am UTC](https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543/3 "2016-05-26T09:16:33Z")

</div>

Cheers for that Torben, but I’m wanting to use CBEffects rather than Corona’s particle system.

Anyone else have an idea?

---

<div class="post-metadata">

**Author:** ![redninjacat](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/r/a4c791/32.png) [@redninjacat](https://forums.solar2d.com/u/redninjacat)\
**Post date:** [May 26, 2016, 2:31pm UTC](https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543/4 "2016-05-26T14:31:48Z")

</div>

Below is some sample code that uses a timer to change the angle of the laser, both the velocity and the rotation of the individual particles. Hopefully, this points you in the right direction.

```
local angle = 0 timer.performWithDelay(100, function() angle = angle - 5 end, -1) local angles = CBE.newVent({ title = "angles", preset = "lasergun", onCreation = function(particle, vent) particle:setVelocity(10 \* math.cos(angle\*(math.pi/180)), 10 \* math.sin(angle\*(math.pi/180))) particle.rotation = angle end, }) angles:start()
```

---

<div class="post-metadata">

**Author:** ![Caleb\_P](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@Caleb\_P](https://forums.solar2d.com/u/Caleb_P)\
**Post date:** [June 17, 2016, 11:30am UTC](https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543/5 "2016-06-17T11:30:25Z")

</div>

Hi and sorry for not seeing this sooner.

This is built into CBE:

```
vent.angles = {10, 15, 20} vent:resetAngles() -- Use this to make the vent recalculate particle trajectories

```

- Caleb

---

<div class="post-metadata">

**Author:** ![torbenratzlaff](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/t/c2a13f/32.png) [@torbenratzlaff](https://forums.solar2d.com/u/torbenratzlaff)\
**Post date:** [May 25, 2016, 5:45pm UTC](https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543/6 "2016-05-25T17:45:27Z")

</div>

An emitter object has the “angle” property, as stated in the docs.

[https://docs.coronalabs.com/api/type/EmitterObject/index.html](https://docs.coronalabs.com/api/type/EmitterObject/index.html)

Mabye you could ajust it to your needs?

---

<div class="post-metadata">

**Author:** ![Appletreeman](https://forums.solar2d.com/user_avatar/forums.solar2d.com/appletreeman/32/130_2.png) [@Appletreeman](https://forums.solar2d.com/u/Appletreeman)\
**Post date:** [May 26, 2016, 9:16am UTC](https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543/7 "2016-05-26T09:16:33Z")

</div>

Cheers for that Torben, but I’m wanting to use CBEffects rather than Corona’s particle system.

Anyone else have an idea?

---

<div class="post-metadata">

**Author:** ![redninjacat](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/r/a4c791/32.png) [@redninjacat](https://forums.solar2d.com/u/redninjacat)\
**Post date:** [May 26, 2016, 2:31pm UTC](https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543/8 "2016-05-26T14:31:48Z")

</div>

Below is some sample code that uses a timer to change the angle of the laser, both the velocity and the rotation of the individual particles. Hopefully, this points you in the right direction.

```
local angle = 0 timer.performWithDelay(100, function() angle = angle - 5 end, -1) local angles = CBE.newVent({ title = "angles", preset = "lasergun", onCreation = function(particle, vent) particle:setVelocity(10 \* math.cos(angle\*(math.pi/180)), 10 \* math.sin(angle\*(math.pi/180))) particle.rotation = angle end, }) angles:start()
```

---

<div class="post-metadata">

**Author:** ![Caleb\_P](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/c/ee7513/32.png) [@Caleb\_P](https://forums.solar2d.com/u/Caleb_P)\
**Post date:** [June 17, 2016, 11:30am UTC](https://forums.solar2d.com/t/cbeffects-rotate-vent-to-match-object-rotation/339543/9 "2016-06-17T11:30:25Z")

</div>

Hi and sorry for not seeing this sooner.

This is built into CBE:

```
vent.angles = {10, 15, 20} vent:resetAngles() -- Use this to make the vent recalculate particle trajectories

```

- Caleb
