Hi. I need the "Is Touched" node to be enabled with an input so I can get it to do active / non active. I´m sure it´s just to make an input, label it Enabled and then a tiny code, but have no idea on to how write the coding. I looked into other nodes that has this code like Touch node but I can´t get it to work. Anyone?
Hi and thanks for the reply. I need to add the code inside is touched to give the node an enable input so I can activate it with an if collide or other. Atm it is activated all the time.
It would help if i know what youre trying to achieve in the game. What do you want to happen? I know what youre saying you need so you can do whatever it is....but WHAT is it? If i know that, i am confident i can figure out how to achieve it. You are requesting code to be added but a lot of times thats not needed and theres another way to do it. So explaining what it is youre doing in the game will help me.
Hi IMO, there is no good way to enable nodes in Buildbox, like on / off. Let´s say you want a button that is turned on during gameplay and when its turned on you can touch it 1 time and then its turned off again (like a panic button). I am able to do that with using a statemachine and a UI button (since it has an input enable) but then I need to have a button on the UI which I really don´t want to have since its a hassle when exporting for Iphone vs Ipad (misplacement) It would be much simpler and better to use global counter to activate the "is touched node" (which don´t have an input) and after 1 touch its de-enabled. Btw, if you are good at coding a lot of users are looking to get a point multiplier node for double ups. Example: After X amount of points multiply points by X After Y amount of points, multiply points b Y Also need a reset pin for the whole thing that can be activated by and if collide or similar This way we can make 2X, 4X, 6X points, and so forth Let me know if any of this is doable App Nasty
here you go. @AppNasty he was trying to enable or disable the is touch so it won't be triggered at any point just in specific scenarios. Although I think this is not the right way to pair it with if collide nodes it might work as intended up to a point. Below you have the code that you requested: Code: /// let lastSig = false; let enabled = false; function init() { this.enableTouch(); let mode = this.attribute('Mode'); let ent = this.entity(); let cam = ent.camera(); let touchTestFunc; if (mode == 'kAABB') { touchTestFunc = function (pt) { if(!enabled) return; let aabb = ent.worldAABB(); let ray = cam.screenRay(pt); let result = ray.intersectsAABB(aabb); // log('aabb', result.hit, result.distance); let isTouched = result.hit; if (isTouched != lastSig) { this.emitSignal('Touched', isTouched); lastSig = isTouched; } }; } else if (mode == 'kRaycast') { touchTestFunc = function (pt) { if(!enabled) return; let ra = cam.screenRay(pt); let to = new Vec3( ra.origin.x + (ra.direction.x * 100), ra.origin.y + (ra.direction.y * 100), ra.origin.z + (ra.direction.z * 100)); let rtst = this.scene().physicsWorld().rayTest( ra.origin, to, ent ); let isTouched = rtst.bodies.length > 0; if (isTouched != lastSig) { if(!enabled) return; this.emitSignal('Touched', isTouched); lastSig = isTouched; } } } component.touchBegan = touchTestFunc; if (this.attribute('Send On Move')) { component.touchMove = touchTestFunc; } } function start() { } function update(dt) { } function signal(name, value) { if (name == 'Enabled') { enabled = Math.abs(value) == 1; } } component.touchBegan = function () { } component.touchMove = function () { } component.touchEnded = function (pt) { if(!enabled) return; this.emitSignal('Touched', false); lastSig = false; }
I wonder if SWITCH node would be useful as well? Awesome job VLAD. Hopefully it is exactly what he needs.
Hurray! I have friends in the universe! This worked perfect Thanks a lot to both involved! Really appreciated this
Question. Is this useful for a RECEIVE node? For example i have a UI button with a SEND node linked to an IS TOUCHED node. Then i place a RECEIVE node in object that connects to a random color change node. Can i use this touch node instead? I added "Enabled" and pasted the code in but when connected to a receive node nothing happens.
On left side i have Enabled and right is Touched. Maybe i did it wrong. Also all i did was delete all code from an IS TOUCHED node and pasted yours in.
Yes. All settings are there as i just erased all code from a normal IS TOUCHED node and replaced it with your code.