After I leave the sprite it returns to original direction

G

greenoozie

Guest
It's been a long while since I have been here at the Forums, and I asked this question about 8-110 years ago, but the solution eludes me now. So... I (player) jump on (press Y) a horse (object) ride it around, and it faces the correct direction and everything, then I get off the horse while it is facing (variable) but the horse doesn't stay looking that direction. How do I make it so that that horse retains the direction it is facing when I get off it? How do I retain the direction instance id of the horse, which may never be used again, I might get on another horse, and ride off into the sunset, but I want the original horse to retain the direction it was facing when I got off it.

Game Maker 8
 
Last edited by a moderator:

Simon Gust

Member
You would have to show us your code.
How are you handling the horse's direction? If the player jumps on the horse and you control the player by changing his directions, should the horse not also apply this direction so when you get off the horse the direction stays?
To me this sounds like you are resetting the horse somewhere.
 
G

greenoozie

Guest
First, I have no idea how to copy/paste the code into the forums. BUT... Basically, the Player is now the sprite of the 'horse' so I move that sprite around just fine, it looks perfect, it is only when I turn the sprite into the man form again, and leave behind a copy of the horse, facing the correct direction, it automatically flips back to the default position. There was a way to "remember" that particular instance's stats, and direction separate from all other instances.

When I say I have no idea, I mean no idea how to extract specific code from the Gamemaker to a clipboard so that I can paste it here..

Code:
Mouse Event for Joystick 1 Button 7:

for all puse: destroy the instance <------ When I press the Y Button to get out of car, it creates a new object that tests if collision with a car object, destroys itself and starts the whole car control object.  

for all Score: execute code:

 playercar.x = plypos.x
 playercar.y = plypos.y
 Score.carhlth = lives

stop sound carrunning
for all Score: if carcolor is equal to 0
      for all interfacecontrols: create instance of object crimsonauto at position (playercar.x,playercar.y)
for all Score: if carcolor is equal to 1
      for all interfacecontrols: create instance of object redspauto at position (playercar.x,playercar.y)
for all Score: if carcolor is equal to 2
      for all interfacecontrols: create instance of object yellowauto at position (playercar.x,playercar.y)
for all Score: if carcolor is equal to 3
      for all interfacecontrols: create instance of object copee at position (playercar.x,playercar.y)
for all Score: if carcolor is equal to 4
      for all interfacecontrols: create instance of object greenauto at position (playercar.x,playercar.y)
for all Score: if carcolor is equal to 6
      for all interfacecontrols: create instance of object brwnauto at position (playercar.x,playercar.y)
for all Score: if carcolor is equal to 5
      for all interfacecontrols: create instance of object blueauto at position (playercar.x,playercar.y)
for all Score: if carcolor is equal to 7
      for all interfacecontrols: create instance of object chopmoto at position (playercar.x,playercar.y)
for all Score: if carcolor is equal to 8
      for all interfacecontrols: create instance of object Taxi at position (playercar.x,playercar.y)
change the instance into object mancontrols, yes performing events
for all playercar: destroy the instance
for all CarControls: destroy the instance
for all CarLance: destroy the instance
 
Last edited by a moderator:

Simon Gust

Member
If you say copy the horse I assume you are creating another instance of it on the spot. If that is so, you can modify the variables including the direction of the new instance.
Code:
var inst;
inst = instance_create(x, y, obj_horse);
inst.direction = direction;
Something like this.

If you are using the function instance_copy you can do the same as the function returns the id of the copied instance.
Code:
var inst;
inst = instance_copy(false);
inst.direction = direction;
 
G

greenoozie

Guest
By George!!!! I think we've got it!!! I'll test it and see and report back. Thank you very much Simon for helping me out here :D

Shoot... right track, but needs to be specific to how I am placing the replica cars.

What is happening is that if I am driving a Red Car, that when I "get out of it" I want it to stay pointing in the right direction. Only that red car. Your code is exactly what I am looking for, but Placement of that code is pretty tricky... do you have any suggestions on this?
 
Last edited by a moderator:
Top