Author Topic: is there a way to make an actor move in the direction the Ego is pointing?  (Read 6458 times)

0 Members and 1 Guest are viewing this topic.

Offline stateofpsychosis

okay so I got guns working in my game,
but I can only get it to shoot at an actor or prop when it's on the screen
because I'm using the MoveTo command

is there a command that will allow me to move the actor for the bullet in whatever direction the ego is facing so that the user can shoot the gun randomly without there being a target?

don't worry, you still have to build the gun. this isn't call of duty :P

oh, I guess I also need to know how to make it maintain the direction the ego is facing when the ego's view switches to the shooting gun view.

just had an idea for something like (if(send gEgo:loop(0))
                                                        (bulletMan:setMotion(MoveTo nsRight)) )
                                                       ... same thing for each loop (direction) etc

   and if that works.....  (if(send gEgo:loop(0))
                                      (send gEgo:view(41) setCycle(Fwd) loop(0)) /// the view change for the                         ego shooting the gun...
....then i'd repeat that for each loop and maybe that'll do it??

don't think that'll work though.. ran out of time to try stuff today
anyways, like I said above I'd like to know if there's a better way to do this with a different command if this doesn't work
« Last Edit: December 12, 2014, 02:32:19 PM by stateofpsychosis »



Offline Cloudee1

Re: is there a way to make an actor move in the direction the Ego is pointing?
« Reply #1 on: December 12, 2014, 05:59:29 PM »
Reply, you are very close... checking the ego loop is the right first step. I would probably do it with a switch myself, and your nsright left stuff I would swap out with ego's x and y.

(switch(send gEgo:loop)
 (case 0 // facing right...
            (bulletMan:ignoreActors()
                             posn((send gEgo:x) (- (send gEgo:y) 25))
                             setMotion(MoveTo 320  (- (send gEgo:y) 25))
            )
            (send gEgo:view(41))
 )// ends case ego loop 0
)// ends switch

I would probably take it one step further and actually trigger a changestate in a shooting gun instance. That way, after a few cycles you can change your ego back to its regular view as well as its regular walk cycle, as well as toss in a programControl at the start of the ego animation and a playercontrol at the end of it. Without taking away control of the ego, the user can press an arrow button in the middle of it and start moving making things look all kinds of not right.
« Last Edit: December 12, 2014, 06:04:14 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline stateofpsychosis

Re: is there a way to make an actor move in the direction the Ego is pointing?
« Reply #2 on: December 15, 2014, 01:54:19 PM »
ahhh

actually that's perfect because i already have a changestate being triggered in there for the robot exploding.

thanks man

at least I was close this time :P

Offline stateofpsychosis

Re: is there a way to make an actor move in the direction the Ego is pointing?
« Reply #3 on: December 16, 2014, 10:22:44 AM »
that worked great :)

I think I'm going to have to build separate scripts for this stuff now though since I'm starting to get heap issues again...

all you gotta do to call an outside script is

Load(SCRIPTNAME_SCRIPT)

right?

cause I tried it and it failed giving me an indecipherable error message...

I'm guessing this is due to the global variables for X and Y needing to be within the room script they have to do with....  I'll have to figure out a way to keep them in the roomscript while pulling the rest out for a separate script I guess. I'll keep tinkering...

I thought that everything done in one room would automatically disload but when i restart the game and re-enter the room... that's when i get the heap error
weird
it could have to do with sci audio as well but i doubt it since this didn't start before this newest update

right now I'll use the show memory command to isolate the issue

still though... thanks the guns are working great now
actually better than the ones in space quest 0 that I saw cause the bullets in this one go strait and don't curve

update: I was able to stop the heap error on restart by changing the line in the main script for the restarting so it went to the title screen instead of to the first room
   
      // Start the room
      (if(GameIsRestarting())
          (self:newRoom(TITLESCREEN_SCRIPT))
       )(else
          (self:newRoom(TITLESCREEN_SCRIPT))
       )
   )
I'll still need to address my memory issues in general though
« Last Edit: December 16, 2014, 01:16:32 PM by stateofpsychosis »


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.043 seconds with 22 queries.