Troubles disabling script on event:

i believe it works because it did work but i need it to update to say that im done reloading but ill try what you said

1 Like

And did you get the laser to look at the player?

No i cant seem to figure it out at all everytime i think i had it the laser still just changed its own position

Let’s do the remaining two levels today. After that, we can both work on the shooter.

Ok im fine with that i really want to see what happens when we enter this into the game jam

1 Like

Meet you in 10 minutes

Most of the games are 2d and Pygame, so we have a good chance.

1 Like

I dont know about ten minutes im about to go somewhere for i dont know about 45 mins ill be back at about 11:05 US East time (am) and ill complete it then

Sure, see u then Nathan

This is the super simple PointAt script I created for the purpose of having a pointer that could point at different parts of an item. This is a mod of the script used in the Hotspot demo project. The only complication/new thing is that the pointer also stretches to reach the item it was pointing. You should be able to apply this to any object and it will point the negative Z to whatever you specified. You may want to disable the scaling feature … though it can make it easier to see what is pointing to what because it will stretch the negative Z toward the target.

Maybe put this or the pointing script you are using into a simple project and toy with that a bit.

var PointAt = pc.createScript('pointAt');

PointAt.attributes.add("targetEntity", {type: "entity", title: "Target Entity"});

// initialize code called once per entity
PointAt.prototype.initialize = function() {
    this.defaultForwardDirection = this.entity.forward.clone();
    this.directionToTarget = new pc.Vec3();

// update code called every frame
PointAt.prototype.update = function(dt) {
    var targetPosition = this.targetEntity.getPosition();
    var pointerPosition = this.entity.getPosition();
    var pointerScale = this.entity.getLocalScale();

    var distance = pointerPosition.sub(targetPosition).length();
    pointerScale.z = distance;
    // Always face the target postition
1 Like

Thanks, we’ll try this. If it doesn’t work, could you please help us fix it? This is pretty urgent.

That script probably contains the sum total of my knowledge on the subject. :^)

No, I didn’t mean help us script it.

I meant could you please help us do this👆?

I’ve made a super simple project called Gun Project that illustrates both methods.

I’ve made a Box that has a rectangular “barrel” oriented in the proper -Z direction but that also has a round “barrel” oriented in the wrong +X direction. Each of these boxes is parented to an “empty” or Null Entity.

I applied the pointAt.js to the box named “Box Proper -Z” and I’ve also applied a shifter.js to it so that you can move the box around with a right-press and drag of the mouse. I have set the pointAt Target to the conical target entity.

For the identical box and barrels labeled “Box Fixed with NULL” I have applied the same scripts to its master Null instead. I’ve then rotated “Box Fixed with NULL” by 90 degrees on the Y axis in its initial Editor settings. So the Null is still pointing its -Z axis at the cone Target because that’s what the lookAt function does. But because the box has been rotated 90 degrees, the round barrel that was pointing in the wrong direction is now pointing at the cone Target. This is the adjustment that fixes the “wrong” initial object orientation.

Right-click and drage and you can see that the boxes will point at the Target. You can change the targets to the Camera in Editor and see that the boxes and their barrels re-orient to point toward the camera. You can raise and lower the boxes and see that they stay pointing at the camera. This is hard to see because this orientation causes very subtle changes in perspective. But that is evidence that they are pointing at the camera as is the fact that the shadows shift as well.

This should be enough to illustrate the two methods, correct orientation and using a Null to adjust for an incorrect orientation.

Note: I disabled the scaling feature of the pointAt.js for this demonstration project.

1 Like

Thanks a lot, you put our project back on track. @Nathan_Hawkins1, take a look.

hmmm how would you could you keep the arrow on the players screen though is not what you want @DevilZ have the closest objective on screen pointing to the objective on the z axis?

I found an alternative, take a look.

Right now, it just alerts a message, but when we get a game over screen, I’ll switch scenes to that.

1 Like

If this is a question you are asking me, I don’t understand the question. If not, please ignore this post.

Ok what i meant is if you had a 2d triangle on the screen pointing toward the objective how would that work?