2 questions to you guys.

GoliBroda

Member
Hi there.
I got two questions, "how to do it type questions" xD i just cant figure out it.
First is:
That i need for a combat system. I got targeted enemy(like in dark souls) and what i need to do is to do kinda animate player to make a hit. But i not mean sprite animation. I need to slowly move back my player some distance backwards, like he gathering power to attack then move fast straight to target to hit him.
I was thinking about some ways to do it but all seems crappy.

2nd thing is to make character jump at rpg maker like tiled map. Jumping is piece of cake but what i want to do is to make that character to drop shadow (it will looks better and inform player where character will fall). Yeap and this is kinda problematic for me.
Player character is wearing many pieces of armor and those pieces are at player.x and y locations (with some added or subtracted amounts.)
I wanted to do an obj for the shadow and pin it to player x and y too, but how to force the shadow to dont jump with player?
 
1) Use a state machine. When the player is powering up an attack, before you change to the powering up state, save the players current x and y position.

Then move the player backwards until the attack is charged. At that point, change to attack state. In the attack state, the player will move from the charged up position back towards the x and y position you saved previously

Is your game top down or side on? Depending on that you would do something like this:
2) When the player is in a jumping state, only change the shadows x position to match the players x position, and leave the y position of the shadow the same.
 

GoliBroda

Member
1) Yeap, but i cant do it. I dont know how to make player to move smoothly, you know, not teleport but automaticly move back, and if its possible with diffrend speed, start moving back slowly at start and keep accelerating till his destination and same with dashing the enemy. Something like when you are creating paths.
And what i forgot to mention is i want player to go back in the opposed direction than the enemy is.
2)It dont seems it will works.
My game isnt side on or top down. its like in rpg maker like i said. and my character can move diagonally. so this could work only if the character go left or right and then jumping. what with going up or down? I could do the same but with y only, but then whats when player is going at any diagonally side .

So i dont think your advices was really helpfull, or maybe i dont understand something.
 
Last edited:
K

Kuro

Guest
So i dont think your advices was really helpfull, or maybe i dont understand something.
I think if you don't understand the answer to a question you yourself asked, rather than insinuating that the answer that someone took the trouble of posting wasn't helpful, I'd look at whether or not you were asking the right questions to begin with? If you post a very broad question, you're going to get a broad answer. It's up to you to break general answers back down into steps that can be implimented, or be more specific with what you're asking in the first place.
 
Last edited by a moderator:

GoliBroda

Member
i did something like this in my scr_backndash combo script
dashed = 0 - this is player create event.
Code:
if dashed = 0{
    speed = 4
    direction = point_direction(obj_player.x,obj_player.y,obj_target.x,obj_target.y)+180 //This is code for go in oposed direction to enemy
        }
if distance_to_object(obj_target)>200{
    dashed = 1
    speed = 25
    direction = point_direction(obj_player.x,obj_player.y,obj_target.x,obj_target.y)
    }
if distance_to_object(obj_target)<40{
    speed = global.movespeed
    scr_space()  //this is code for attack and dont bother the bottom codes its for combo system.
    ComboSlot[1] = 0
    ComboSlot[2] = 0
    ComboSlot[3] = 0
    ComboSlot[4] = 0
    ComboSlot[5] = 0
    CS = 0
    cmbDMG = 0
    cmbDMGarmor = 0
    }
I think it's the crappy way to do it but it could work.
could but not working and i dont know why.
when the code is executed my character go back (oposed direction to the enemy) but when distance to enemy is more than 200 he is not stopping, not changing the direction, he continues going away from enemy.
If i delete first if code (skip the part with going away from the enemy) everything is working fine, i mean character is dashing an enemy with 25 speed, stops 40px before him, hits him and resets all combo variables.
I dont know why it is not working, i think it shoult working without even if dashed = 0{, i mean if i just type the spped and direction at the very first lines of code.

@Edit
there's 2 comments in code for you guys.
 
That's a pretty good effort actually, the code is very similar to what I had in mind, minus the state machine.

I believe that programming needs to be learnt by doing. I will write code sometimes when it's non-obvious or I feel like it or I have the time.

If I was in your situation at the moment, I would use the debugger to step through the code and figure out exactly what it's doing.

The logic seems ok to me.

Is obj_target an instance id or an object index?

If it's an object index, one possibility of why it's not working would happen if you have more than one "obj_target" instance in the room.

In this case, your point_direction may be picking one of the instances, but the "distance_to_object" may be picking another instance that is further than 200 pixels away, so the player will just keep moving away.
 

GoliBroda

Member
There can be few targets, but it happens even if only one is activated.
and keep on mind that other codes uses obj_target too. so i think it's not that (but i belive it could causing some problems in future.)

and i have set a breakpoint at this code:
if distance_to_object(obj_target)>200{
and the game is not stopping after player run away from monster at the distance.
i cant even imagine what could cause the problem.
btw, still crappy method. What if i want to "animate" my characters in other ways like moving on the arc etc.
 
Top