Press specific key to change an object's collisionGroup
3 posts • Page 1 of 1
- AN9K
- Posts: 5
- Joined: Tue Jun 30, 2015 12:14 am
Re: Press specific key to change an object's collisionGroup
Not really...
The code is much simpler actually. You have to use keys.isDown("key"), keys.bind is only to bind keys to the GUI
First of all: If you write on onKey, your script will run more efficiently (no lag while not pressing the key) but when you release the key the script will not update (this means, you're saying: If you're pressing this key, change collideSet, if you release, change it again - but when you release it the script will not change the collideSet as it is not active). SO what you have to do is put it on the collideSet property itself (or on postStep or update if you want, but the script is shorter on collideSet)
So it will be like this:
That will make the object collision layer A and C when you press V, and only C when you release it
If for some weird reason you wanted to write that down on postStep or update, then do this:
The particular thing about this code is that you'll be able to see which collideSet is active while the scene is running, from the script menu itself
If you need more help just ask. hope you don't do algicosathlon, whoever you are...
The code is much simpler actually. You have to use keys.isDown("key"), keys.bind is only to bind keys to the GUI
First of all: If you write on onKey, your script will run more efficiently (no lag while not pressing the key) but when you release the key the script will not update (this means, you're saying: If you're pressing this key, change collideSet, if you release, change it again - but when you release it the script will not change the collideSet as it is not active). SO what you have to do is put it on the collideSet property itself (or on postStep or update if you want, but the script is shorter on collideSet)
So it will be like this:
- Code: Select all
collideSet = {
keys.isDown("v") ? 5:4
}
That will make the object collision layer A and C when you press V, and only C when you release it
If for some weird reason you wanted to write that down on postStep or update, then do this:
- Code: Select all
postStep(or update, same) = (e)=>{
collideSet = (keys.isDown("v") ? 5:4)
}
The particular thing about this code is that you'll be able to see which collideSet is active while the scene is running, from the script menu itself
If you need more help just ask. hope you don't do algicosathlon, whoever you are...
- The Linkage
- Posts: 57
- Joined: Fri Aug 05, 2011 5:40 pm
- Location: Escobar, Argentina
Re: Press specific key to change an object's collisionGroup
AN9K wrote:Is this code correct?
- Code: Select all
OnKey=(e)=>{
collisionGroup = (Keys.bind == 'v') ? 5 : 4
}
No.
keys.bind is interface customization for your PC only. Than bindings not saved with scene.
Use onKey or keys.isDown instead.
http://www.algodoo.com/forum/viewtopic.php?f=13&t=10580&start=0
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
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 9 guests