Raycast.prototype.doRaycast = function (screenX, screenY) {
var from = this.entity.getPosition();
var to = this.entity.camera.screenToWorld(screenX, screenY, this.entity.camera.farClip);
var result = this.app.systems.rigidbody.raycastFirst(from, to);
if (result) {
this.app.renderLine(from,to,this.color);
}
};
Hello @jus.co_ding_me_23! It does not answer your question, but if you want to post some of your code, please do it correctly so that your code is easier to read.
var Raycast = pc.createScript(‘raycast’);
Raycast.attributes.add(‘color’, {type : ‘rgba’});
// initialize code called once per entity
Raycast.prototype.initialize = function() {
this.app.mouse.on(pc.EVENT_MOUSEDOWN, this.mouseDown, this);
};
// update code called every frame
Raycast.prototype.update = function(dt) {
};
Raycast.prototype.mouseDown = function(e){
this.doRaycast(e.x, e.y);
};
Raycast.prototype.doRaycast = function (screenX, screenY) {
var from = this.entity.getPosition();
var to = this.entity.camera.screenToWorld(screenX, screenY, this.entity.camera.farClip);
var result = this.app.systems.rigidbody.raycastFirst(from, to);
if (result) {
this.app.renderLine(from,to,this.color);
}
};
Render line is meant to be for debugging only. I would use something else to represent the rope such as a model (like a cylinder) that you can scale or generate a mesh.
Render line will also only render the frame that the function is called. If you want to see it all the time, you need to call the function every frame.
i have left that game I was making @yaustar . Playcanvas is a good engine, but it can’t be used fir some specific stuff. The setTimeout also has a tiny bug.
i mean, i have used unity, and i can do stuff way more. Here some themed games like shooters or something, this is ‘good’, or ‘manageable’ but when it comes to full fletched games or stories or stuff, playcanvas is stilll in the ameature zone, saying that,those type of games are IMPOSSIBLE.
Unity does offer a lot of stuff out of the box that we don’t have. At the same time, the size of download in the browser compared to Unity is much smaller.
It’s part of the reason why developers of games like venge.io choose to use PlayCanvas over Unity.
All that said, choose the right tool for you. There’s no point using something if it’s not making you productive.
i like playcanvas though. I tried unity. It was good, but i couldnt publish it well. One advantage of playcanvas, even with some tiny bugs and errors in my code,playcanvas is simple to use. That’s why Im using it. (It might even be better than babylon). but please add more 2d stuff. I am a 2d guy. i used to use unity and construct 3, but this is simple and works well on browser, one question, how do you make playcanvas games available on the play store, i saw something like that in the tutorials.